I am trying to add a reference 'Newtonsoft.Json.dll' I have followed what he has asked. which adds this ref from 'browse' tab to 'recent' tab. If I look at the list of refs from the ref list it is listed but with a yellow flag.
Its probably something in your build system: the dll is likely getting cleaned (as in deleted by a rebuild), or is in a directory that isn't under your solution, or simply isn't getting copied to the output directory.
I'm sorry I don't have a more specific piece of advice. What I'm going to do though is suggest you use a shot-gun to kill a mosquito: use NuGet. In C# with Visual Studio (or any other .net IDE), you really want to use the nuget package manager, since it works so well.
Make sure that the your project target framework is set to the correct version. It might be that your target .NET framework for the project is lower than what the Newtonsoft dll was built under. Right click on your project and see what it's set at. You'll need to go view the properties.
I downloaded Json.NET here. Inside binaries, choose the one that matches your .Net Framework version, add the dll inside a folder of your project (e.g. lib), and include it as a reference. Then, have fun!
Add the assembly to GACBefore we can use our assembly, we have to add it to the global assembly cache (GAC). Open the Visual Studio 2008 Command Prompt again (for Vista/Windows7/etc. open it as Administrator). And execute the following command.gacutil /i d:\myMethodsForSSIS\myMethodsForSSIS\bin\Release\myMethodsForSSIS.dll
Errors related to newtonsoft.json.dll can arise for a few different different reasons. For instance, a faulty application, newtonsoft.json.dll has been deleted or misplaced, corrupted by malicious software present on your PC or a damaged Windows registry.
In the vast majority of cases, the solution is to properly reinstall newtonsoft.json.dll on your PC, to the Windows system folder. Alternatively, some programs, notably PC games, require that the DLL file is placed in the game/application installation folder.
Do you have information that we do not?
Did our advice help or did we miss something?
Our Forum is where you can get help from both qualified tech specialists and the community at large. Sign up, post your questions, and get updates straight to your inbox.
I'm able to run the test for my project from my solution. However, when I try to use this dll from VFP I'm getting this error: One or more errors occurred. Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
You need to make sure you have the right version of Newtonsoft.Json. wwDotnetBridge binds to a specific version of this library and if you're accessing a different one it's not going to work unless you set a few configuration settings in the yourApp.exe.config and vfp9.exe.config.
You shouldn't have to set a reference to that library at all, if your .NET assembly has a reference to it. You need to make sure when you copy (or build) your project to the folder you are consuming the DLL from that it also includes newtonsoft.json.dll as that's a dependency.
If you're using one of the West Wind versions (not the open source one) then you'll need to use the config settings described in the post. Otherwise it should probably just work once your FoxPro code can find the dependency dll(s).
With the help of my colleague and after using a different laptop I eventually was able to fix my own project (by fixing it on the other laptop, renaming the bad directory on my old laptop, getting from TFS fixed solution) and the test from the project now works fine on both laptops.
However, test from VFP is still failing (and I haven't installed VFP on my new laptop at all). I'm using a test program in VFP development environment and I placed my dll and the newtonsoft.json.dll (latest version 11.0.0.2) into the folder where I'm executing my test program from. I'm still getting that same error which makes no sense at all. In my own solution I have this app.config:
Just to be sure, I added loading newtonsoft.json assembly file using LoadAssemly before loading my dll.Both LoadAssembly worked fine, but the method from my class is still failing with the exact same error ?
I'm trying to test from a prg directly from VFP. In my test program I instantiate my class and then from that class I'm running a method which in turn tries to call a method from my .NET class which sends json request and receives back json response. All the dlls are in the same folder from where I'm running this test VFP program. Yet I'm still getting that exact error.
The issue here is that something is referencing a very old version of Newtonsoft.Json. If it's your code, it shouldn't be referencing this old version but whatever is current (ie. v11.x or so). If there is another dependency that relies on an old version then the redirects are required to ensure that the old versions are forwarding 'pretend' to be of the newer version. But you have to make sure that hte config file is set and that the version you specify there exactly matches the newtonsoft.json.dll that's on disk.
There's nothing wrong with the dev environment - this is a versioning issue with DLLs but these things can be difficult to track down. Also make very sure you have the right version of wwDotnetBridge that you think you are using. If you're using an old version of a West Wind Client Tools/Web Connection those versions a long time ago referenced v6.0 which makes me think maybe there is an old version involved somewhere.
When I first read your message, I thought the problem may be coming from the other dll which did have a reference to west wind client tools. So I fixed that project, removed that reference, etc., but the problem persisted. I since then got rid of that dll, but the problem still remains. I created a zip file with my .net dll solution and a simple VFP test program. I'm ready to share it but don't know your email to share with you only.
You need to do this for vfp9.exe.config and for yourApp.exe.config for the deployed compiled application. Not the dlls - that won't work with FoxPro loaded assemblies - all settings have to be in the .exe.config file.
The question I have, though - I sent the link to Boris and he also got that same error. In that link I only had your wwDotNetBridge libraries from the distribution folder which I downloaded very recently + my dll which uses latest Newtonsoft.Json.dll + VFP test program. I sent that link to you too.
Anything loaded from a Zip file and downloaded over the internet has to be unblocked in order to be able to run. Otherwise you'll get security exceptions from Windows. I suspect that's what you're actually seeing. .NET DLLs have to be either copied as part of a proper install (ie. admin rights installed) or you need to unblock.
Other than that if your code runs on one box it should run on another assuming you have the same binaries on both. There's nothing that should be different there assuming you are running the same code. If you're not running the same code, then there's likely something else going on.
Your scenario you are doing is pretty complex and involves several layers of indirection. It can certainly work but you're basically dealing with 4 different environments that are interacting with each other: C++, COM, FoxPro and .NET with COM in between two separate layers. I wouldn't be surprised if there are problems along that path due to various context switches that have to occur.
My dll uses latest version of newtonsoft. So, forgetting for a moment the complex scenario we're going to use it from, why I and Boris are getting this error in the first place. My colleague also got that exact same error from that test I prepared.
If you want to run without a config file you have to use the same version those DLLs are using which is difficult because they are not available on NuGet. So yes, you have to use a config file with the assembly redirect.
Anyway, I think it is not a big deal to add the config file as long as I understand which config file we would need to distribute. Say, our C++ application is called Sales32.exe and I'm not developing this application. Do I need to make sure that we're using that config file with the Sales32 (which, BTW, is run from different directory from where my VFP dll resides)?
Ah - yeah that makes sense. The Newtonsoft.Json.dll isn't loaded until you access functionaltiy in it, so you won't see the error until you call a method that references it. I just ran your code and I assumed that code would reference the code.
The working dll doesn't use the static properties (they are private variables) and doesn't use static methods. That's the only difference I can see. I originally coded not working dll exactly as the one which is working, but it didn't work for some reason, so I used the code which is used in many online samples for sending request and receiving a response. Do you think that difference may contribute to this weird issue? ?( I may try re-writing dll back to be the same as "working" one.
Where is this manifest and where does it try to load this version from?????? My reference file is indeed the latest version. I'm trying to figure out what am I missing in my solution? May be I should try to zip my directory in case I could not figure this out?
You likely have some other dependency that pulls in an old version of the JSON dll. Or maybe an old version of wwDotnetBridge? But none of this should matter matter. Just create the .config file for VFP and your app, set the version to whatever the actual dll version is and it will work.
We have the config for our Sales application (even two of them). Still it doesn't work. I don't understand - should I also add VFP9.exe.config into the same directory where we're running our Sales application from? Or in the directory where we have wwDotNetBridge.dll and our .NET dll and our VFP dll calling .NET dll by the means of the wwDotNetBridge?
c80f0f1006