Share via


CLRInterop::getObjectForAnyType Method

Converts a value of the X++ anytype data type to a value of the CLRObject data type.

Syntax

client server public static CLRObject getObjectForAnyType(anytype anyType)

Run On

Called

Parameters

  • anyType
    Type: anytype
    The X++ value to convert to a value of the CLRObject data type.

Return Value

Type: CLRObject Class
The CLR object that has the value of the _anytype argument.

Remarks

If an attacker can control input to the getObjectForAnyType 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 the CLRObject type, an exception of the Exception::CLRError type is thrown.

Examples

The following example converts a string value to a CLR string object.

static void Job3(Args _args) 
{ 
    CLRObject clrObj; 
    InteropPermission perm; 
    System.String s; 
 
    perm = new InteropPermission(InteropKind::ClrInterop); 
    if (perm == null) 
    { 
        return; 
    } 
    perm.assert(); 
     
    s = CLRInterop::getObjectForAnyType("Calculate total"); 
  
    CodeAccessPermission::revertAssert(); 
}

See Also

Reference

CLRInterop Class