.net – type or namespace name ‘Newtonsoft’ could not be found

json.netnet

I've looked this question up, but I don't see too many answers, and obviously none have been helpful or I wouldn't be asking. I am a .NET neophyte.

My local environment is Win7, Microsoft Virtual Web Developer 2010 Express. I added the NewtonSoft.Json as a custom component library.

  • I built a simple "HelloWorld" web service, using Newtonsoft.Json custom components.

  • When I do a build on my local machine (Visual Web Developer 2010 Express) it works great. I actually get a valid JSONP output, not XML.

  • When I FTP my files to the remote web server, my web service does not work. I get this:

Compilation Error Description: An error occurred during the
compilation of a resource required to service this request. Please
review the following specific error details and modify your source
code appropriately.

Compiler Error Message: CS0246: The type or namespace name
'Newtonsoft' could not be found (are you missing a using directive or
an assembly reference?)

Source Error:

Line 7: using System.Web.Services.Protocols;

Line 8: using System.Web.Script.Services;

Line 9: using Newtonsoft.Json;

Line 10:

Line 11: namespace System.Web.Script.Services.CS

I have tried everything from copying my entire project folder to the remote folder, then deleting everything and just copying my asmx and web.config file, and I still get the error. I copied the bin folder, with the Newtonsoft.Json.dll to the remote server, then tried copying it into the root folder, and to no avail.

Is there some operation that must be performed on the remote server to enable it to use Newtonsoft.Json.dll?

Best Answer

When you copy files of a solutions, some references can be "lost". Try to delete the reference and add it again, after you copied the files and open in the other machine.

Also, take a look at this question: reference dll not copying to bin with deployment project causing error

Related Topic