CLRObject.new Method

Creates an instance of the CLRObject class.

Syntax

public void new(str className, [ params])

Run On

Called

Parameters

  • className
    Type: str
    The name of the CLR class to be instantiated.
  • params
    Type: [T:]
    The arguments for the constructor of the CLR class to instantiate.

Remarks

Instances of the CLRObject class are used to wrap values that are returned from calls to common language runtime (CLR) methods.

If an attacker can control input to the new method, a security risk exists. Therefore, this method runs under Code Access Security. Calls to this method on the server require permission from the . Ensure that the user has development privileges by setting the security key to SysDevelopment on the control that calls the new method.

If a new ClrObject object fails to be instantiated, the Exception:Internal exception is thrown. To obtain the original CLR exception, call the CLRInterop::getLastException method.

Examples

This example creates a new System.Int32 CLR object.

void ClrObjectExample() 
{ 
    CLRObject clrObj; 
    InteropPermission perm; 
    anytype retVal; 
  
    perm = new InteropPermission(InteropKind::ClrInterop); 
    if (perm == null) 
    { 
        return; 
    } 
  
    perm.assert(); 
  
    clrObj = new CLRObject("System.Int32"); 
  
    CodeAccessPermission::revertAssert(); 
}

See Also

Reference

CLRObject Class