Click here to Skip to main content
15,887,240 members
Please Sign up or sign in to vote.
1.60/5 (2 votes)
See more:
I have Meta search engine program that I wrote with C#. It uses both Bing and Google search API for its results. Now I want to add duckduckgo search API to my program. the problem is when I add the duckduckgo's library in the references, it says that both google and duckduckgo have the search class in their library and it couldn't recognize which one to use and I want to use both search engines in my program.

What I have tried:

As I can't change the class name in the library how should I fix the problem?
Posted
Updated 16-Dec-16 2:26am

1 solution

You can specify which one you want to use by adding namespace prefix.

Example:

C#
var search = new Google.API.Search();

where 'Google.API' is the namespace (use actual class namespace, this is just an example)
 
Share this answer
 
v2
Comments
Atiiiii 16-Dec-16 8:44am    
Where can I find the actual namespace of this class?
jimmson 16-Dec-16 8:50am    
There are several ways in Visual Studio, by using Object browser, by using tooltips.. I recommend to learn more about namespaces, it will be much clearer then! https://msdn.microsoft.com/en-us/library/dfb3cx8s.aspx

Atiiiii 16-Dec-16 10:57am    
I've read the page and found the namespace,thanks!but now when I add it throws this exception : "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."
I have also download and add newsoft.jason.net35.dll but it didn't fix the exception, do you know the solution?
jimmson 16-Dec-16 11:21am    
Try look at the inner exception (and inner of inner and so on). There's a big chance this not relate to the original question. :)
Atiiiii 16-Dec-16 11:44am    
the inner exception says this:
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 should I do?

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