Calls a public method on the .NET object or a static method of a .NET type. If parameters have been set with the DotNetSetXX methods, these parameters will be passed in the order of the DotNetSetXX calls. If you want to call a static method you have to use the constant DOTNET_STATIC_METHOD as object handle for the DotNetCallMethod and the DotNetSetXX methods. Another way to pass parameters to and from the method is to use the AttributeXX functions. The .NET Method can use the perfDotNetFW.dll to call into the Silk Performer runtime to get/set attributes (Bdl.AttributeGet, Bdl.AttributeSet).
If the function returns a value, this value can be retrieved with the DotNetGetXX methods. Again - if calling a static method - use DOTNET_STATIC_METHOD as object handle.
DotNetAPI.bdh
DotNetCallMethod( in hObject : number, in sMethodName : string, in sTypeName : string optional, in sAssembly : string optional, in sTimer : string optional ): boolean;
true if successful
false otherwise
Parameter | Description |
---|---|
hObject |
Handle to a .NET Object or DOTNET_STATIC_METHOD if you want to call a static method. In this case you have to at least specify the name of the .NET type (class) you want to call the method. |
sMethodName | Method that should be called |
sTypeName |
(optional) If you want to call a static method this parameter specifies the .NET type (class) of the method. |
sAssembly |
(optional) If you want to call a static method and this parameter is omitted the type specified in sTypeName is searched in the currently loaded assemblies. If you haven't loaded the assembly where sTypeName is implemented you can specify the assembly file here and it will be loaded. Assemblies are normally loaded during DotNetLoadObject. The basic .NET assembly (mscorlib) is always loaded - so you can access all static methods of the basic classes. |
sTimer |
(optional) If defined – a custom timer will be generated to measure the execution time of the method call. |
dcltrans transaction TMain var hObject, nValue : number; begin // load an object and call a method on this instance hObject := DotNetLoadObject("C:\\MyDotNet\\Bin\\Release\\MyDotNet.dll", "MyDotNet.TestClass"); DotNetCallMethod(hObject,"TestMethod"); DotNetFreeObject(hObject); // call a static method - no additional assembly needs to be loaded because DateTime is defined in mscorlib DotNetSetInt(DOTNET_STATIC_METHOD, 2003); DotNetSetInt(DOTNET_STATIC_METHOD, 2); DotNetCallMethod(DOTNET_STATIC_METHOD, "DaysInMonth", "System.DateTime"); DotNetGetInt(DOTNET_STATIC_METHOD, nValue); end TMain;