0

So I have an ASP.NET website, which works great on my machine. But when I deployed it on web host server, its giving me an error saying:

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 15: using Microsoft.VisualBasic;
Line 16: using System.Data.SqlClient;
Line 17: using Newtonsoft.Json;
Line 18: using System.Globalization;
Line 19: using System.Text.RegularExpressions;

I think this is a classic error, and there are similar questions already being asked, even by me before. But, all the solutions are either not clear or not applicable.

Since its a "website" project, so the property of the aspx.cs file does not contain any field such as "Build Action" or "Copy Local" etc. I am using Newtonsoft to parse JSON. Can someone please suggest me STEP-BY-STEP way to get rid of this problem?

I came across solutions such as clean-up and such. Clean what? In my solution explorer, there's this BIN folder which contains the dll, xml, and pdb for the Newtonsoft library; which is AS-IT-IS copied on to the webhost server, using COPY WEBSITE tool.

What do I need to do to fix the problem? Thanks a bunch.

Community
  • 1
  • 1
Dev Dreamer
  • 289
  • 1
  • 9
  • 18
  • 1
    Did you copy `newsoftxxx.dll` inside the `Bin` folder? – KV Prajapati Aug 23 '12 at 12:05
  • what's newsoftxxx.dll ? There's none with this name, there's a Newtonsoft.Json.dll, Newtonsoft.Json.xml, and Newtonsoft.Json.pdb. All exist locally and in the Bin folder in the webhost. Thanks. – Dev Dreamer Aug 23 '12 at 12:13
  • When you publish it, and deploy on the web host server, do you have in that Bin folder (not in your development enviroment) the dll? – Gonzalo.- Aug 23 '12 at 12:35
  • I used the copy website tool to deploy on the web host server, and yes, its there. Screenshot: http://i.imgur.com/K95OE.png – Dev Dreamer Aug 23 '12 at 12:39

3 Answers3

1

This would happen if you're not deploying to an application root, but a normal windows folder.

The bin folder must be in your application root (~/bin) for assemblies to be resolved correctly. You may change this by changing your private probing path in your web.config-file, but that's a bad solution for this.

Ensure you're uploading your application to an folder configured to host an application. This can be done in your IIS Manager if you have Remote Desktop access. Shared hosting solutions may provide this functionality in a web-based configuration tool. Log into your "control panel" and look around.

Or you could just contact your hosting support.

sisve
  • 19,501
  • 3
  • 53
  • 95
0

Take these steps: -> Solution explorer window -> right mouse on your .cs file in Visual Studio -> select Properties -> Build action = Compile

or

Remove reference of your Newtonsoft and copy Newtonsoft.dll to your bin folder and give a reference from there.

J. Steen
  • 15,470
  • 15
  • 56
  • 63
Anant Dabhi
  • 10,864
  • 3
  • 31
  • 49
  • Hi, thanks for help. Option 1 is not possible, as its a "website" project, and there's no such option in the property of which. For Option 2, can you please describe how do I do that? I don't quite get it. Step-by-step explanation would be highly appreciable. "Give a reference from there" - where? how? Thanks. – Dev Dreamer Aug 23 '12 at 12:50
  • @J. Steen please help. Thanks. – Dev Dreamer Aug 23 '12 at 13:04
  • first make sure Newtonsoft.dll exists in bin folder – Anant Dabhi Aug 23 '12 at 13:37
  • it does: http://i.imgur.com/K95OE.png Please suggest what else to do? Thanks a lot. – Dev Dreamer Aug 23 '12 at 13:38
0

Build your website and publish it to some folder. Then copy all requisite files to your web server. Just check whether you got Newtonsoft dll in bin folder (web server) or not. If you do not have, then copy it from local machine and paste it to web server.

Amnesh Goel
  • 2,617
  • 3
  • 28
  • 47