CLRInterop.staticInvoke(String, String, Object[]) Method

Definition

Calls a static method on a CLR data type.

public:
 static System::Object ^ staticInvoke(System::String ^ typeName, System::String ^ methodName, cli::array <System::Object ^> ^ parameters);
[Microsoft.Dynamics.Ax.Xpp.VarArgs]
public static object staticInvoke (string typeName, string methodName, object[] parameters);
[<Microsoft.Dynamics.Ax.Xpp.VarArgs>]
static member staticInvoke : string * string * obj[] -> obj
Public Shared Function staticInvoke (typeName As String, methodName As String, parameters As Object()) As Object

Parameters

typeName
String
methodName
String

The arguments, if there are any, to the method that is specified in the _methodName parameter.

parameters
Object[]

Returns

The CLRObject that contains the value that is returned by the static CLR method; otherwise, nullNothingnullptrunita null reference (Nothing in Visual Basic).

Attributes

Remarks

If an attacker can control input to the staticInvoke 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 an error occurs when you call the get_Now method, the Exception::ClrError exception is thrown.

The following example calls the get_Now method on the System.DateTime CLR class and prints the results in the Infolog.

static void Job7(Args _args) 
{ 
    CLRObject clrObj; 
    InteropPermission perm; 
    System.DateTime dateTime; 
    perm = new InteropPermission(InteropKind::ClrInterop); 
    if (perm == null) 
    { 
        return; 
    } 
    perm.assert(); 
    dateTime = CLRInterop::staticInvoke( 
                   "System.DateTime", 
                   "get_Now" ); 
    info(dateTime.ToString()); 
    CodeAccessPermission::revertAssert(); 
    pause; 
    // This is the same code using CLR syntax. 
    // dateTime = System.DateTime::get_Now(); 
    // info(dateTime.ToString()); 
}

Applies to