Hello,
Can we call Westwind.Utilities methods from VFP?
I'm trying to use Westwind.Utilities.StringUtils.RandomString in VFP.
But wwDotNetBridge tells 'No such interface supported.'
DO wwDotNetBridge
loBridge = CreateObject("wwDotNetBridge","V4")
? loBridge.LoadAssembly("...\Westwind.Utilities.dll")
? loBridge.cERRORMSG
loFox = loBridge.CreateInstance("Westwind.Utilities.StringUtils")
? loBridge.Invokestaticmethod(loFox,"RandomString", 5, .T.)
And if I use the following instead:
loBridge.Invokestaticmethod("Westwind.Utilities.StringUtils","RandomString", 5, .T.)
it says the method "Westwind.Utilities.StringUtils.RandomString" not found.
I appreciate if you could let me know what I'm missing.
Thanks,
Kathy
Sure that should work, but make sure you got the right version of the DLL. I think RandomString is fairly new. Best to check with Reflector or other IL tool to see what the signature is on the DLL you're actually calling.
+++ Rick ---
Hmmm... took a look and sure enough I can't make that work either.
It seems to be some sort of parameter mismatch.
I even tried:
loVal = loBridge.CreateComValue()
loVal.SetValueFromSystemConvert("ToInt32",10.00)
? loVal.Value
? loBridge.InvokeStaticMethod("Westwind.Utilities.StringUtils","RandomString",loVal, .t.)
But even that seems to fail.
I can't look at this closer as I don't have the .NET code with me on this travel machine but it looks like it's a perhaps an issue with InvokeStaticMethod that's not properly mapping the parameters. It looks like other methods that are passing INT values are also failing (like Replicate()
) in the same way.
+++ Rick ---
Aha - I figured out why it's not working 😃
The issue is that wwDotnetBridge includes this class internally. But it's old and it doesn't include the newer methods like RandomString. The typename is the same, and wwDotnetBridge is using the first loaded instance (the second one never loads).
So... calling this method is not going to work due to this conflict.
I can't recall offhand if wwDotnetBridge uses features from these classes internally - I think it does and that's why they are there.
It might be a good idea for me to explicitly rename the namespaces of the internally used methods so that the external types work.
For now - it's not going to work calling RandomString()
. To see what's available in the internal classes take a look at wwDotnetbridge.dll with Reflector.
+++ Rick ---
And thanks for introducing the cool tool "Reflector".
Didn't know it before.
Kathy
Hi Kathy,
Give a try to the updated wwdotnetbridge.dll
in https://west-wind.com/files/WebConnectionExperimental.zip. I've updated the internal dependencies to use a different namespace so they should no longer interfere with the actual Westwind.Utilities classes. All the new internal namespaces are going to be Westwind.WebConnection
instead of Westwind.Utilities
.
FWIW, I'm also adding the latest StringUtils to wwDotnetBridge internally, but it's not yet in this build. It'll be Westwind.WebConnection.StringUtils
and will have the same functions as the full version so you may not have to ship the Westwind.Utilities
dll in the future.
Update:
I've updated the DLL and the new Westwind.WebConnection.StringUtils
is now in the wwdotnetbridge.dll
in the zip file.
+++ Rick ---