Dynamics AX 4.0 & COM InterOp
In DAX 4.0 a greater level of security is implemented, in that you have to assert different types of permission classes when performing different functions. If for example the InteropPermission class is not used in conjuction with calls to COM objects you might run into a similar message as below:
Error: "Request for the permission of type 'InteropPermission' failed."
Basically this is because there was a COM call without first creating an instance of the InteropPermission and then asserting correct security permission in order to interact with the said / given COM calls.
If you are an Admin of a system, then you want run into this, but if you are a normal user then you will. This is a good point to say you always need to preform unit testing as a given process user, vs. in admin mode. With that said, below is an example of how to call and use the InteropPermission:
COM com;
InteropPermission permission = new InteropPermission(InteropKind::ComInterop);
;
permission.assert();
com = new COM(namespace.classname);
So you have to .assert(); before you can work with the COM object. In doing so you then successfully enable the given code to execute properly without security errors. You should always encapsulate your code in try{} catch{} blocks to handle Any errors properly.
Check back for more as we explore File IO security, and preforming both COM and IO work in the same scope of code, and dealing with asserting at different levels.
Find a job at: www.DynamicsAXJobs.com
Error: "Request for the permission of type 'InteropPermission' failed."
Basically this is because there was a COM call without first creating an instance of the InteropPermission and then asserting correct security permission in order to interact with the said / given COM calls.
If you are an Admin of a system, then you want run into this, but if you are a normal user then you will. This is a good point to say you always need to preform unit testing as a given process user, vs. in admin mode. With that said, below is an example of how to call and use the InteropPermission:
COM com;
InteropPermission permission = new InteropPermission(InteropKind::ComInterop);
;
permission.assert();
com = new COM(namespace.classname);
So you have to .assert(); before you can work with the COM object. In doing so you then successfully enable the given code to execute properly without security errors. You should always encapsulate your code in try{} catch{} blocks to handle Any errors properly.
Check back for more as we explore File IO security, and preforming both COM and IO work in the same scope of code, and dealing with asserting at different levels.
Find a job at: www.DynamicsAXJobs.com
0 Comments:
Post a Comment
<< Home