VFP and .NET Interop
Class wwJsonSerializer - Error on DeserializeJson() Function
Gravatar is a globally recognized avatar based on your email address. Class wwJsonSerializer - Error on DeserializeJson() Function
  Ron
  All
  Jun 2, 2017 @ 01:04pm

Getting "Type not loaded, Please load call LoadAssembly first" error when running sample code below. I have included a screen shot of the debugger stating the loadassembly can not be evaluated. I'm using all the required ww files and .net version is v4.0.30319. Can anyone provide any solution to what my problem might be.

Thank you,

DO wwJsonSerializer && Load libs

*** Create a complex object
loCust = CREATEOBJECT("Empty")
ADDPROPERTY(loCust,"Name","Rick")
ADDPROPERTY(loCust,"Entered",DATETIME())

*** Create a nested object
ADDPROPERTY(loCust,"Address", CREATEOBJECT("Empty"))
ADDPROPERTY(loCust.Address,"Street","32 Kaiea Place")
ADDPROPERTY(loCust,"Number",32)

loSer = CREATEOBJECT("wwJsonSerializer")

*** Serialize into JSON
lcJson =  loSer.Serialize(loCust)

? lcJson
*{"address":{"street":"32 Kaiea Place"},"entered":"2012-05-12T03:55:35Z","name":"Rick"}

*** read back from JSON into an object
loCust2 = loSer.DeserializeJson(lcJson)

? loCust2.Name
? loCust2.Entered
? loCust2.Address.Street
? loCust2.Address.Number

Gravatar is a globally recognized avatar based on your email address. re: Class wwJsonSerializer - Error on DeserializeJson() Function
  Rick Strahl
  Ron
  Jun 2, 2017 @ 05:24pm

Make sure you have wwdotnetbridge.dll and newtonsoft.json.dll available in your path. It looks like one of those assemblies is not available.

Gravatar is a globally recognized avatar based on your email address. re: Class wwJsonSerializer - Error on DeserializeJson() Function
  Ron
  Rick Strahl
  Jun 3, 2017 @ 06:42am

I have all files necessary for processing example. I have no problem with the Serialize, only deserializejson and specifically the wwdotnotbridge. I see the object getting created in debug on line below, but it has no properties, methods, etc.

*** Turn handle into IDispatch COM object this.oDotNetBridge = SYS(3096, lnDispHandle)

Could there be some kind windows security not allowing me access to the handle/ref created from SYS(3097, this.oDotNetBridge)?

Gravatar is a globally recognized avatar based on your email address. re: Class wwJsonSerializer - Error on DeserializeJson() Function
  Rick Strahl
  Ron
  Jun 3, 2017 @ 08:33pm

What is the type that comes back? It's coming back NULL is what I'm guessing which means either you don't have the right version of .NET installed or wwDotnetBridge is not being found.

To check try this:

  • Shut down VFP and restart
  • CD into your application folder
    (same environmnet when you run your app)

Then do this:

do wwdotnetbridge
loBridge = GetwwDotnetBridge("V4")
? loBridge.GetDotnetVersion()

If that still fails you likely are missing a valid version of .NET 4.0 on your system. Check here or to be sure install the latest .NET version.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Class wwJsonSerializer - Error on DeserializeJson() Function
  Ron
  Rick Strahl
  Jun 4, 2017 @ 09:32am

According to my debugger, this.oDotNetBridge is an Object. See first post. Ran your code and .Net Version came back as 4.0.30319.42000. I tried running sample code on another PC and got same results. It's got to be something stupid in my environment going on, we know it is not code. let me look into it tomorrow, I will get back with you if I can't get it to work.

Thank you, Ron

Gravatar is a globally recognized avatar based on your email address. re: Class wwJsonSerializer - Error on DeserializeJson() Function
  Rick Strahl
  Ron
  Jun 4, 2017 @ 06:31pm

If the code snippet I posted works wwdotnetbridge is working. The problem then has something to do with loading a dependent assembly which would be the Newtonsoft.json.dll.

Are you sure that assembly is in the same path you're loading wwdotnetbridge from (or anywhere along your Foxpro path).

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Class wwJsonSerializer - Error on DeserializeJson() Function
  Ron
  Ron
  Jun 26, 2017 @ 07:20am

Hey Rick, it must had been the version of the wwjsonserializer or wwdotnetbridge I was running. I replaced, and it ran fine.

© 1996-2017