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

Thanks for comments.....

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer