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 by using a fully qualified type name instead of an instance.
o.InvokeStaticMethod(lcTypeName, lcMethod, lvParm1, ... lvParm10)
Return Value
Result value - check the Error flag for errors
Parameters
lcTypeName
The fully qualified type name (ie. 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
loBridge = GetwwDotnetBridge()
lcPath = loBridge.InvokeStaticMethod("System.Environment","ExpandEnvironmentVariables","%appdata%\Markdown Monster")
See also:
Class wwDotNetBridge© West Wind Technologies, 2023 • Updated: 06/03/20
Comment or report problem with topic