Click here to Skip to main content
15,889,372 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a meta search engine program wrote in C#. It worked well with google and Bing search API.when I wanted to add duckduckgo API,it said that the search class is both in google and duckduckgo and couldn't recognized it,I add the namespace before it and it solved the problem but now it throws this exception and doesn't work at all.I don't know where the problem is and what caused the exception.

the exception says:
C#
An unhandled exception of type 'System.TypeInitializationException' occurred in Google.Apis.dll

Additional information: The type initializer for 'Google.Apis.Json.NewtonsoftJsonSerializer' threw an exception.


and the inner exception says:

"Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"

What I have tried:

I've download and add newtonsoft.jason.net35.dll to the program but it still doesn't work.anyone could help me about this?
Posted
Updated 16-Dec-16 6:36am
Comments
Afzaal Ahmad Zeeshan 16-Dec-16 12:41pm    
You should use NuGet package manager to install this instead of copying and pasting downloaded stuff.

Did you add the appropriate "using" statement to your source file?
 
Share this answer
 
Comments
Atiiiii 16-Dec-16 12:27pm    
yes I did that
The loader can't find the referenced assembly.

The way I do it is to put 3rd party assemblies into a folder inside my solution, and reference that copy of the DLL. That way, there are no versioning issues.

If you added the json library with NuGet, there's a folder in your solution called "packages". Delete the reference and re-add it, pointing to the file in that folder.
 
Share this answer
 
Comments
Atiiiii 16-Dec-16 12:43pm    
I didn't understand this part:"The way I do it is to put 3rd party assemblies into a folder inside my solution, and reference that copy of the DLL. That way, there are no versioning issues."
and in the second part you mean that I remove the reference from the program and re-add it how?
sorry I'm not native English speaker :(
#realJSOP 16-Dec-16 13:31pm    
The manifest file doesn't match the dll. Make sure you're adding a reference that has the correct manifest file in the same folder. It's best to delete the reference, get the assembly from nuget, and let it add the reference for you.
Atiiiii 16-Dec-16 13:59pm    
Ok which package I should download from Nuget after deleting newtonsoft.json from references ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900