type or namespace name 'Newtonsoft' could not be found
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?
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
Thanks for the pointer and the link. After a struggle I got it to work. What finally happened was my friend, an expert in .NET Skyped me and talked me through the proper way of deploying my project to the destination server. I didn't understand that there is a separate folder where your Build goes. I made a "Build Deployment Package" as a zip file. Then I unzipped it on my hard drive, and dropped it into a clean folder on the web server (actually, I uploaded it to the root directory), and voila, it worked.
Another possible reason for this issue is if the project is using NuGet packages and they haven't been restored (downloaded) yet.
They may need to be restored in Visual Studio or you can use the nuget.exe command-line executable to restore the packages.
https://docs.nuget.org/consume/package-restore
链接地址: http://www.djcxy.com/p/11034.html上一篇: 使用node.js覆盖文件中的一行