Newtonsoft namespace type or name could not be found

I looked through this question, but I do not see too many answers, and obviously, none of them were useful, or I would not ask. I am .NET neophyte.

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

  • I created a simple HelloWorld web service using the custom components of Newtonsoft.Json.

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

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

Compilation Error Description: An error occurred while compiling the resource required to service this request. Please review the following specific error information and change the source code accordingly.

Compiler Error Message: CS0246: The type or namespace name "Newtonsoft" could not be found (are you missing the using directive or the 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: System.Web.Script.Services.CS namespace

I tried everything: from copying the entire project folder to the deleted folder, and 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 file to the remote server, and then tried to copy it to the root folder and to no avail.

Is there any operation that needs to be performed on the remote server so that it can use Newtonsoft.Json.dll?

+7
source share
3 answers

Thanks for the pointer and link. After the fight, I made her work. Finally, it was my friend, an expert in .NET. I downloaded it and told me how to correctly place my project on the target server. I did not understand that there is a separate folder in which your assembly is going. I made the "Build Deployment Package" as a zip file. Then I unzipped it to my hard drive and dropped it into a clean folder on the web server (in fact, I uploaded it to the root directory) and worked with it.

0
source

When you copy solution files, some links may be "lost." Try deleting the link and adding it again after copying the files and opening it on another computer.

Also, take a look at this question: dll link does not copy to bin with deployment project causing error

+3
source

Another possible cause of this problem is that the project uses NuGet packages and they have not yet been restored (downloaded).

You may need to restore them in Visual Studio or you can use the nuget.exe command line executable to restore packages.

https://docs.nuget.org/consume/package-restore

0
source

All Articles