wwDotNetBridge::InvokeStaticMethod

This method allows you to call a static .NET method such as System.Windows.Forms.MessageBox.Show() for example. Because the methods are static you can't create an instance and pass it back to FoxPro, instead this method has to be used to invoke a method.

o.InvokeStaticMethod(lcTypeName, lcMethod, lvParm1, ... lvParm10)

Return Value

Result value - check the Error flag for errors

Parameters

lcTypeName
The fully qualified type name (System.Net.Mail.MailMessage)

lcMethod
The method to call on the type.

lvParm1..lvParm10
Up to 10 parameters for the method call.

Remarks

If you get 'Invalid Method' or 'Method not found' type errors most likely you are calling the method with missing or invalidly typed parameters.

In some cases you may have to explicitly coerce parameter types by using the VFP CAST() function. This is especially true for numeric values since VFP numbers are typically passed as double or int depending on the existance of decimals. For example, decimal values need CAST(1.11 as Currency) or CAST(10 as int).

You can also use the ComValue class to explicitly force parameter types to specific types, including types that you cannot set directly from FoxPro such as Single, Long, Byte and numerous others.

To pass ByRef/Ref parameters use ComValue objects instead of plain parameter values. ComValue parameters will always be updated after returning from a method call.

Example

*** Simple Method Invokation:

loNet = loBridge.Createinstance("Westwind.WebConnection.TypePassingTests")
? loBridge.InvokeMethod(loNet,"HelloWorld","Rick")
*** Note this is the same as:
loNet.HelloWorld("Rick")


*** Pass ByRef parameters and return values:

*** Create ComValue objects for each parameter
loInt = loBridge.CreateComValue(INT(10))
loString = loBridge.CreateComValue("Hello World.")
loDecimal = loBridge.CreateComValue(CAST( 5.22 as Currency))

? "Original:"
? loInt.Value, loString.Value, loDecimal.Value

lobridge.InvokeMethod("Westwind.WebConnection.TypePassingTests",;
                      "PassByReferenceStatic",;
                      loInt,loString,loDecimal)

*** Look at the result values
? "Updated:"
? loInt.Value, loString.Value, loDecimal.Value

See also:

Class wwDotNetBridge

© West Wind Technologies, 1996-2019 • Updated: 06/07/17
Comment or report problem with topic