FoxPro Programming
Signature dll
Gravatar is a globally recognized avatar based on your email address. Signature dll
  Vincent H.
  All
  Mar 18, 2025 @ 10:17pm

Hi Rick,

I'm using a native library for signature generation and validation in DLL format.

The C functions it contains are initialized in VFP with the DECLARE command.

I sometimes encounter a memory management issue with the message "Declare DLL call caused an exception"

Could wwDotnetBridge help me?

Thanks in advance for your help.

Gravatar is a globally recognized avatar based on your email address. re: Signature dll
  Rick Strahl
  Vincent H.
  Mar 19, 2025 @ 10:25am

Not directly. wwDotnetBridge is for .NET components, it doesn't do anything for native C++ code. You could create a wrapper DLL and do the Interop from .NET which might provide more options, but I doubt that that will significantly help and if you can do it from .NET there's likely a way you can do the same in FoxPro.

I suspect the issue isn't the VFP DECLARE code, but most likely some issue inside of the native code that's causing the problem - probably allocating memory and not releasing it, but impossible to know. If that's the case there's nothing that can fix this other than a fix to the library itself.

+++ Rick -

Gravatar is a globally recognized avatar based on your email address. re: Signature dll
  Vincent H.
  Rick Strahl
  Mar 19, 2025 @ 10:10pm

Thanks for your reply.

Regarding the VFP error, you're of course right; a CLEAR DLL on one of the inputs causes the error.

The good news is that there's a C# version of this DLL, which I'm trying to use!

But I can't reproduce this command:

request = OtSignatureRequestFactory.getXmlSignatureRequest()

Even though my library is loaded correctly

loBridge.loadassembly (MyDll-cs) = .T.

For example, I tried this (without success):

Mreq = loBridge.invokemethod("OtSignatureRequestFactory", "getXmlSignatureRequest")

Gravatar is a globally recognized avatar based on your email address. re: Signature dll
  Rick Strahl
  Vincent H.
  Mar 20, 2025 @ 12:30pm

Look at the method signature in a .NET decompiler (like ILSpy) to see what the constructor looks like. Most likely the constructor (or method(s)) doesn't have a parameterless version and you need to make sure you match one of the constructor parameter signatures EXACTLY.'

.NET supports optional parameters, but that doesn't work for Reflection based or direct COM access so you have to match the exact method/ctor signatures. This makes reading examples more difficult because the C# code often will use defaults leaving out parameters that are required with COM.

Also case matters.

Also if a method doesn't work direct (as you're doing) you may have to use loBridge.InvokeMethod() depending on parameter and return types and whether they are supported by COM and FoxPro.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Signature dll
  Vincent H.
  Rick Strahl
  Mar 21, 2025 @ 12:55am

Thanks Rick,

ILspy is extremely useful!

Here are two lines of code in C#:

1. request = OtSignatureRequestFactory.getXmlSignatureRequest();
2. request.setSignatureProfile(profile);

loRequest = loBridge.InvokeStaticMethod("com.opentrust.spi.sdk.OtSignatureRequestFactory", "getXmlSignatureRequest") returns me an object variable.

But how do I invoke line 2. ?

Gravatar is a globally recognized avatar based on your email address. re: Signature dll
  Rick Strahl
  Vincent H.
  Mar 21, 2025 @ 09:15am

But how do I invoke line 2. ?

You get back an object so call it directly, or use loBridge.InvokeMethod() if the direct call doesn't work (depends on the signature). Same drill - make sure you match parameters exactly.

+++ Rick ---

© 1996-2025