Share via


DLLFunction.call(Object[]) Method

Definition

public:
 virtual System::Object ^ call(cli::array <System::Object ^> ^ objArray1);
[Microsoft.Dynamics.Ax.Xpp.VarArgs]
public virtual object call (object[] objArray1);
[<Microsoft.Dynamics.Ax.Xpp.VarArgs>]
abstract member call : obj[] -> obj
override this.call : obj[] -> obj
Public Overridable Function call (objArray1 As Object()) As Object

Parameters

objArray1
Object[]

Returns

Attributes

Remarks

If an attacker can control input to the call 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.

The following example uses the DLL and DLLFunction classes to interoperate with the GetVersion API in Kernel32.dll. It asserts the use of the InteropPermission class to provide code access protection, and then it loads the DLL. If this is successful, the return type is set from the call to the DLLFunction class.

{ 
    Dll               dll; 
    DllFunction       dllFunc; 
    anytype           retVal; 
    InteropPermission perm; 
    perm = new InteropPermission(InteropKind::DllInterop); 
    // Grants permission to execute the DLL.new method. 
    // DLL.new is protected by code access security. 
    perm.assert(); 
    dll = new Dll("Kernel32.dll"); 
    // Closes the code access permission scope. 
    CodeAccessPermission::revertAssert(); 
    if (dll != null) 
    { 
        // Grants permission to execute the DLLFunction.new method. 
        // DLLFunction.new is protected by code access security. 
        perm = new InteropPermission(InteropKind::DllInterop); 
        perm.assert(); 
        dllFunc = new DllFunction(dll, "GetVersion"); 
        if (dllFunc != null) 
         { 
            dllFunc.returns(ExtTypes::DWord); 
             retVal = dllFunc.call(); 
         } 
       // Closes the code access permission scope. 
       CodeAccessPermission::revertAssert(); 
    } 
}

Applies to