West Wind Toolkit for .NET
wwDotNetBridge question
Gravatar is a globally recognized avatar based on your email address. wwDotNetBridge question
  Robert
  All
  Jan 18, 2022 @ 12:56pm

Hello Rick, I am trying to access some properties in a .NET DLL without success. We have purchased and have used for several years a library from IDScan.net (https://idscan.net/sdkdownloads/) to parse a scanned driver license for age verification in our VFP application. I am trying to access some properties about the license so that we know what to renew. However, I am not having any success getting to it.

Here is a sample.

loBridge = GetwwDotNetBridge()
loBridge.LoadAssembly("dlplib.dll")

loDLParse = loBridge.CreateInstance("Nautilus.DriverLicense")

loDLStatus = loBridge.CreateInstance("Nautilus.DlplibLicenseStatus")

*-various ways I have to tried to get to the ExpirationDate
*-According to IDScan tech support the ExpirationDate should be available after calling the method GetDlpLibLicenseStatus

? loBridge.InvokeMethod(loDLStatus, "GetDlpLibLicenseStatus()")
? loBridge.GetProperty(loDLStatus, "ExpirationDate")
? loDLStatus.ExpirationDate

*-I tried to access via loDLParse 
? loBridge.InvokeMethod(loDLParse, "GetDlpLibLicenseStatus()")
? loBridge.GetProperty(loDLParse, "ExpirationDate")
? loDLParse.ExpirationDate

The only return value I get is: ExpirationDate: 12/30/1899 12:00:00 AM

On the invoke method on loDLStatus I get: OLE IDispatch exception code 0 from wwDotNetBridge: Method 'Nautilus.DlplibLicenseStatus.GetDlpLibLicenseStatus()' not found

And on the invoke method on loDLParse I get: OLE IDispatch exception code 0 from wwDotNetBridge: Method 'Nautilus.DriverLicense.GetDlpLibLicenseStatus()' not found

*-I have tried also without the () on the method call. (same result) loBridge.InvokeMethod(loDLStatus, "GetDlpLibLicenseStatus")

If I try to call the method without using the wwDotNetBridge invoke I get a generic OLE error: e.g. ? loDLStatus.GetDlpLibLicenseStatus() OLE error code 0x80020006: Unknown name

Other methods and properties on loDLParse are working just fine.

The following .NET logic works fine. So I know the method is available.

DlplibLicenseStatus licenseStatus = DriverLicense.GetDlpLibLicenseStatus();
return $"DLL version:{VersionDlplib}\r\n{(licenseStatus.Licensed ? "Licensed" : "Not licensed")}\r\nExpiration Date:{licenseStatus.ExpirationDate:MM/dd/yyyy}\r\nFeatures:{licenseStatus.Features}\r\nPath:{licenseStatus.DlplibLicensePath}";

Any insight would be helpful.

Thank you, Robert.

Gravatar is a globally recognized avatar based on your email address. re: wwDotNetBridge question
  Rick Strahl
  Robert
  Jan 18, 2022 @ 04:17pm

Well for one thing remove the parenthesis from the InvokeMethod() calls. It's just the name of the method.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: wwDotNetBridge question
  Robert
  Rick Strahl
  Jan 19, 2022 @ 09:51am

Rick, I apologize. I had tried that but left the () in my example.

I believe I have some more info that hopefully will help. The dlplib.dll has two objects: Nautilus.DriverLicense Nautilus.DlplibLicenseStatus

Nautilus.DriverLicense has a method called ParseText that I can call just fine From the object browser in visual Studio I can see it is declared as:

public static Nautilus.DriverLicense ParseText(string scanned_text)

Nautilus.DriverLicense has a number of properties that I can access just fine as well after calling this "ParseText" method. From the object browser in visual Studio I can see it is declared as: public string Address1 { get; } Member of Nautilus.DriverLicense

The object Nautilus.DlplibLicenseStatus is a different story. It has a property with an Expiration date From the object browser in visual Studio I can see it is declared as:

public System.DateTime ExpirationDate { get; set; }
  Member of Nautilus.DlplibLicenseStatus

However, this property always returns: 12/30/1899 12:00:00 AM

According to documentation and IDScan Support I need to call a method first to initialize this property. This is where I run into a problem. I need to call the method GetDlpLibLicenseStatus in the Nautilus.DriverLicense object. From the object browser in visual Studio I can see it is declared as:

public static Nautilus.DlplibLicenseStatus GetDlpLibLicenseStatus**([string DlpLicenseFolder = ])  
   Member of Nautilus.DriverLicense

But, notice how it is declared as a type in the Member of Nautilus.DlplibLicenseStatus? So when I call

loBridge = GetwwDotNetBridge()
oDLParse = loBridge.CreateInstance("Nautilus.DriverLicense")
loBridge.InvokeMethod(oDLParse, "GetDlpLibLicenseStatus") 

I always get: Method 'Nautilus.DriverLicense.GetDlpLibLicenseStatus' not found

My limited know how about .NET prevents me from understanding this what appears to be a type conversion or call back method?

Gravatar is a globally recognized avatar based on your email address. re: wwDotNetBridge question
  Rick Strahl
  Robert
  Jan 19, 2022 @ 02:00pm

The parameters are not optional when calling from FoxPro so you need to pass in the string parameter to GetDlpLibLicenseStatus(). .NET supports optional parameters but that's being fixed up by the compiler. When calling externally from FoxPro or anything that uses Reflection as wwDotnetBridge does, you always have to pass all parameters defined in the method signature. This is why typically you can't go purely off code samples, but rather should always look at the actual signatures in Reflector or other tool.

Your method call should probably be this:

loLicense = loBridge.InvokeMethod(loDLParse, "GetDlpLibLicenseStatus", lcLicenseFolder)

You also need to check for errors to make sure the reference to the created object in loDLParse is valid before you make the method call.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: wwDotNetBridge question
  Robert
  Rick Strahl
  Jan 19, 2022 @ 02:51pm

Rick, thank you so much. That was the kick I needed. The call now succeeds and returns an object. I could then query the object property to get the date value.

oStatus = loBridge.InvokeMethod(oDLParse, "GetDlpLibLicenseStatus", lcLocalPath)
IF VARTYPE(oStatus) = 'O' THEN
    dtExpiresDate = loBridge.GetProperty(oStatus, "ExpirationDate")
ENDIF

? 'License Expires on: ' + TTOC(dtExpiresDate)

Thanks so much for your help.

© 1996-2024