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.