CLRInterop.getAnyTypeForObject(Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Converts a common language runtime (CLR) object to a value of the X++ anytype data type.
public:
static System::Object ^ getAnyTypeForObject(System::Object ^ value);
public static object getAnyTypeForObject (object value);
static member getAnyTypeForObject : obj -> obj
Public Shared Function getAnyTypeForObject (value As Object) As Object
Parameters
- value
- Object
Returns
An X++ anytype date type that has the value of the _object argument.
Remarks
If an attacker can control input to the getAnyTypeForObject method, a security risk exists. Therefore, this method runs under Code Access Security. Calls to this method on the server require permission. Make sure that the user has development privileges by setting the security key to SysDevelopment on the control that calls this method. If the argument cannot be converted to an X++ data type, an exception of the Exception::ClrError type is thrown.
The following example sets the value of a CLR string to an X++ str data type.
{
CLRObject clrObj;
InteropPermission perm;
System.String clrStr = "Calculate total";
str s;
perm = new InteropPermission(InteropKind::ClrInterop);
if (perm == null)
{
return;
}
perm.assert();
s = ClrInterop::getAnyTypeForObject(clrStr);
CodeAccessPermission::revertAssert();
}