tag:blogger.com,1999:blog-2154285972274878988.post3899828879522247758..comments2024-03-28T01:19:52.819-06:00Comments on DAX Dude - Dynamics 365/AX: Error: CLR object cannot be marshaled to Microsoft Dynamics anytypeDAXDudehttp://www.blogger.com/profile/15490813518772863345noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-2154285972274878988.post-89758422419374526122016-08-16T08:28:55.877-06:002016-08-16T08:28:55.877-06:00That fixed it thank you very much. I am in 2009.That fixed it thank you very much. I am in 2009.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2154285972274878988.post-67060716135107435832013-12-19T11:36:45.755-07:002013-12-19T11:36:45.755-07:00Just wanted to thank you for helping to find a wor...Just wanted to thank you for helping to find a workaround for a problem that was starting to become a nuisance!chewtoy elevenhttps://www.blogger.com/profile/17498862253417565001noreply@blogger.comtag:blogger.com,1999:blog-2154285972274878988.post-91549142635061251772011-12-20T21:47:03.116-07:002011-12-20T21:47:03.116-07:00Thanks Dax Dude. Am working with Ax 2012.
Now this...Thanks Dax Dude. Am working with Ax 2012.<br />Now this is working fine.sathishhttps://www.blogger.com/profile/07091222583096615770noreply@blogger.comtag:blogger.com,1999:blog-2154285972274878988.post-8988406280042893012011-12-20T11:17:31.197-07:002011-12-20T11:17:31.197-07:00Sathish: if I can guess, you are working in AX 201...Sathish: if I can guess, you are working in AX 2012. This code was designed and used in AX 2009 so I know this post is solid for 2009. I tested the code in AX 2012 and am receiving the marshaling error for both methods same as you.<br /><br />It looks like 2009 and 2012 are different in regards to allowing marshaling on the line: <br />regValue = System.Convert::ToString(clrString)<br /><br />To everyone: That being said, the above will work for 2009 but not 2012. Below is a job that works for marshaling in AX 2012.<br /><br />// December 20, 2011 - DAX Dude<br />static void Job1(Args _args)<br />{<br /> #define.AOSRegistryPath(@'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dynamics Server\6.0')<br /> str axAOSName = "01"; // Your AOS Name here<br /> str axRegLocation;<br /> str axRegAXName = "InstanceName"; // Registry object name in Registry path <br /> //str contents;<br /> System.String netContents;<br /> System.Object netObject = new System.Object();<br /> str xppContents <br /> ;<br /> <br /> axRegLocation = #AOSregistryPath + '\\' + axAOSName;<br /> <br /> //Simple marshaling test...<br /> netContents = 'Test Marshaling .NET string to AX string';<br /> xppContents = netContents;<br /> info (xppContents);<br /> xppContents = 'Test Marshaling AX string to .NET string';<br /> netContents = xppContents;<br /> info (netContents);<br /> <br /> //Fun registry test... <br /> netObject = Microsoft.Win32.Registry::GetValue(axRegLocation, axRegAXName, null); <br /> netContents = netObject.ToString();<br /> info (netContents);<br /> xppContents = netContents;<br /> info (xppContents); <br />}DAX Dudehttps://www.blogger.com/profile/05544317456179314313noreply@blogger.comtag:blogger.com,1999:blog-2154285972274878988.post-79635516626967556042011-12-20T00:45:56.862-07:002011-12-20T00:45:56.862-07:00I tried to run the code in the job, but it is thro...I tried to run the code in the job, but it is throwing the same error.<br /><br />Error: CLR object cannot be marshaled to Microsoft Dynamics anytypesathishhttps://www.blogger.com/profile/07091222583096615770noreply@blogger.comtag:blogger.com,1999:blog-2154285972274878988.post-4799911518106003892011-12-19T19:07:13.789-07:002011-12-19T19:07:13.789-07:00I think I understand what your asking now that its...I think I understand what your asking now that its happy hour... Here is how the code is used in application with AX 2009 variables. I've used this part of code countless times in several different environments. Your variables will be different.<br /><br /><br /><br />#define.AOSRegistryPath(@'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dynamics Server\5.0')<br />str axAOSName = "02"; // Your AOS Name here<br />str axConfigName = "DEV"; // Your Config Name here<br />str axRegLocation;<br />str axRegAXName = "application"; // Registry object name in Registry path <br />str contents;<br /><br />axRegLocation = #AOSregistryPath + '\\' + axAOSName + '\\' + axConfigName;<br /><br />contents = Microsoft.Win32.Registry::GetValue(axRegLocation, axRegAXName, null);DAX Dudehttps://www.blogger.com/profile/05544317456179314313noreply@blogger.comtag:blogger.com,1999:blog-2154285972274878988.post-64672039991710768272011-12-19T07:33:22.147-07:002011-12-19T07:33:22.147-07:00Happy to help but I'm confused with the questi...Happy to help but I'm confused with the question. The code should be able to be used anywhere depending on purpose. I encountered this while creating an automated analysis for performance. Not sure where, or if, this code even exists in base AX code. Worth running a find on the AOT if you're curious.<br /><br />I would actually recommend you copy and paste the code into an AX job and confirm the two ways operate the way I described above. <br /><br />If you are seeing this in a specific area of AX code, please feel free to post the specific questions. I want to make sure everyone sees the threads in case it helps them out too. <br /><br />I can test environments ranging from AX 3.0 SP4 to the latest release of AX 2012 so there shouldn't be a problem there.DAX Dudehttps://www.blogger.com/profile/05544317456179314313noreply@blogger.comtag:blogger.com,1999:blog-2154285972274878988.post-73266366502108852012011-12-19T05:10:57.042-07:002011-12-19T05:10:57.042-07:00Can u please help me out here, exactly where the a...Can u please help me out here, exactly where the above code can be taken.sathishhttps://www.blogger.com/profile/07091222583096615770noreply@blogger.com