0

I have a .NET 4.0 dll that I would like to integrate to Dynamics Ax 2009 on server side. In client side (RunOn: client), it works fine with a 32 bit dll. But on server side (RunOn:server), it doesn't work.

Here is what I do: (1) I copy an instance of the 64 bit dll to the bin folder of the AOS, and (2) I add the the necessary entries to the registry with Regasm.exe.

After I use the following code:

server static void ComIntegrationTest(Args _args)
{
    COM com;
    ;
    new InteropPermission(InteropKind::ComInterop).assert();
    com = new COM('{A2686EE2-8382-3D04-B908-31AF4E5AF5B5}');
    CodeAccessPermission::revertAssert();
}

I receive the following error message: COM object of class '{A2686EE2-8382-3D04-B908-31AF4E5AF5B5}' could not be created. Ensure that the object has been properly registered on computer 'MSS2008R2-AXAOS'. Object 'COM' could not be created

Or if I wrap the COM object in a x++ class with Com class wrapper wizard, and try to make an instance of the wrapper class, I receive following error message: Request for the permission of type 'InteropPermission' failed. Object 'COM' could not be created.

EDIT:

If it is not possible to do it, how can I integrate Dynamics Ax 2009 with .NET 4.0?

It is not possible to directly reference a .NET 4.0 dll that is in the GAC, because Dynamics Ax 2009 is only compatibly with .NET 3.5 or previous versions of .NET.

  • I'm surprised that I haven't seen this question before for AX2009. Below is a link how to make the COM object but from reading the above it appears that you have already taken all of the correct steps. http://blogs.microsoft.co.il/arik/2011/05/30/how-to-use-a-net-4-based-dll-from-net-2-based-application/ – ian_scho Feb 03 '15 at 10:43

1 Answers1

1

I think you are mixing .Net and COM integration, they live on different planets.

You should strongly sign your .Net assembly, then register in GAC.

See also this problem and this description part 1 and part 2.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
  • Thanks for your answer. In Dynamics Ax 2009, It is only possible to use signed .NET 3.5 dlls as clr objects that are registered in the GAC. I have a 3rd party dll that uses .NET 4.0., therefore I cannot do it. Therefore I am trying a COM integration. It works fine in Axapta 3.0. – user3036220 Feb 02 '15 at 15:47
  • When I say COM integration, I mean that I use the following command to register the .NET dll to the registry: regasm /tlb:MyWrapper "MyWrapper.dll". And then I reference it from Dynamics Ax: Com com = new COM('{A2686EE2-8382-3D04-B908-31AF4E5AF5B5}'). – user3036220 Feb 02 '15 at 15:55
  • Do not use `new COM` to reference .Net assemblies. – Jan B. Kjeldsen Feb 02 '15 at 15:56
  • It works on client side in this way (with COM). But I cannot reference it as clr object, if it is in the GAC, because it uses .NET 4.0, and Dynamics Ax 2009 is not compatible with .NET 4. – user3036220 Feb 02 '15 at 16:01