West Wind Toolkit for .NET
Westwind.Utilities.StringUtils.RandomString
Gravatar is a globally recognized avatar based on your email address. Westwind.Utilities.StringUtils.RandomString
  Kathy
  All
  Jul 19, 2017 @ 12:13pm

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

Gravatar is a globally recognized avatar based on your email address. re: Westwind.Utilities.StringUtils.RandomString
  Rick Strahl
  Kathy
  Jul 20, 2017 @ 10:45pm

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 ---

Gravatar is a globally recognized avatar based on your email address. re: Westwind.Utilities.StringUtils.RandomString
  Rick Strahl
  Kathy
  Jul 21, 2017 @ 10:17am

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 ---

Gravatar is a globally recognized avatar based on your email address. re: Westwind.Utilities.StringUtils.RandomString
  Rick Strahl
  Kathy
  Jul 21, 2017 @ 10:55am

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 ---

Gravatar is a globally recognized avatar based on your email address. re: Westwind.Utilities.StringUtils.RandomString
  Kathy
  Rick Strahl
  Jul 21, 2017 @ 12:56pm

Will do.
Thank you so much Rick.
Kathy

Gravatar is a globally recognized avatar based on your email address. re: Westwind.Utilities.StringUtils.RandomString
  Kathy
  Kathy
  Jul 21, 2017 @ 01:12pm

And thanks for introducing the cool tool "Reflector".
Didn't know it before.
Kathy

Gravatar is a globally recognized avatar based on your email address. re: Westwind.Utilities.StringUtils.RandomString
  Rick Strahl
  Kathy
  Jul 24, 2017 @ 02:30pm

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 ---

Gravatar is a globally recognized avatar based on your email address. re: Westwind.Utilities.StringUtils.RandomString
  Kathy
  Rick Strahl
  Jul 24, 2017 @ 08:46pm

I'll make a good use of them for sure.
I really appreciate your help.
Kathy

© 1996-2024