FoxPro and .NET Interop
Variable not found
Gravatar is a globally recognized avatar based on your email address. Variable not found
  Miro
  All
  Jul 29, 2020 @ 12:02pm

After connecting to the DLL, I find a value of variable:

  lLoadOk = oBridge.LoadAssembly("eZdravieSignature.dll")
  lxDllValue1 = oBridge.GetProperty(oEhealthDocas,"ExternyIdentifikatorRiadku")

If this variable "ExternyIdentifikatorRiadku" does not exist, this code ends in error : OLE error code 0x8002000e - Invalid number of parameters

How to verify if variable exists - something like :

  IF TYPE("variable")!="U"
Gravatar is a globally recognized avatar based on your email address. re: Variable not found
  Rick Strahl
  Miro
  Jul 29, 2020 @ 01:29pm

Where is your code to create an instance of the type?

If this is your real code, you need to:

  • Load the assembly
  • Create an instance
  • Then access the property on the instance

In addition you should check for errors on the LoadAssembly() and CreateInstance() calls to make sure these methods actually work.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Variable not found
  Miro
  Rick Strahl
  Jul 29, 2020 @ 02:08pm

If variable "ExternyIdentifikatorRiadku" exist, them this code run O.K. and lxDllValue have real value :

oBridge = CreateObject("wwDotNetBridge","V4")
lLoadOk = oBridge.LoadAssembly("eZdravieSignature.dll")
oController = oBridge.CreateInstance("eZdravieSignature.eZdravieSignature")
oEhealthDocas = oBridge.CreateInstance("eZdravieSignature.WebReferenceEReceptV05.APIDocasnaVZS")
lxDllValue = oBridge.GetProperty(oEhealthDocas,"ExternyIdentifikatorRiadku")

How to screen for the absence of a variable

Gravatar is a globally recognized avatar based on your email address. re: Variable not found
  Rick Strahl
  Miro
  Jul 29, 2020 @ 02:23pm

You should check for errors if it's not working. Your code has no error checking for anything. After each call check the .lError flag and .cErrorMsg.

You can always check for the explicit type of the result value.

*** Check for the type you're expecting
if VARTYPE(oController) # 'O'
   * error handling here
endif
Gravatar is a globally recognized avatar based on your email address. re: Variable not found
  Miro
  Rick Strahl
  Jul 29, 2020 @ 09:44pm

Probably my question is wrong. My code is :

 DO wwUtils
 DO wwDotNetBridge
 PUBLIC oBridge AS wwDotNetBridge
 PUBLIC oController AS wwDotNetBridge
 oBridge = CreateObject("wwDotNetBridge","V4")
 lLoadOk = oBridge.LoadAssembly("eZdravieSignature.dll")
 oController = oBridge.CreateInstance("eZdravieSignature.eZdravieSignature")
 oEhealthDocas = oBridge.CreateInstance("eZdravieSignature.WebReferenceEReceptV05.APIDocasnaVZS")

and this run O.K. This is definition of DLL : I need to test whether the variable is defined and what type it is (e.g. "IdTechnik") to pass on the correct value. How to handle an error if it is not defined in the DLL.

Gravatar is a globally recognized avatar based on your email address. re: Variable not found
  Rick Strahl
  Miro
  Jul 30, 2020 @ 04:29pm

I already answered your question in my last message... You can use VARTYPE() to check for the specific type you are expecting, but you really should be checking for errors not checking the value returned to see whether there's a problem.

+++ Rick ---

© 1996-2020