Error CLR object cannot be marshaled to Microsoft Dynamics anytype in Dynamics Ax

Description:-

I was hitting a problem with marshallinga string from System.String to Str datatype (X++). The error was 'CLR object cannot be marshalled to Microsoft Dynamics anytype' when I tried to convert them using the code below.  This is how I fixed it.

System.String clrString;
str           axString
;
ClrString = Microsoft.Win32.Registry::GetValue(XXXX, XXXX, XXXX);
 
// This way does not work in AX 2012 what you read from text
// axString = clrString;
 
// This is the way the marshaling needs to occur
regValue = System.Convert::ToString(clrString);

Related Posts

Previous
Next Post »

Thanks for comments.....