Missing a using directive or an assembly reference error upon deploying the website

妖精的绣舞 提交于 2019-12-01 13:19:46

问题


I have a website, where the *.cs file lies in the App_Code folder (while adding a class item in my project, VS2010 suggested me to create this folder). I have a default.aspx.cs file which makes use of this class. It runs without any error when I run on VS2010.

However, when I deployed the website on the webserver via a private hosting company. It gives me this error:

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 'SMSAPP' could not be found (are you missing a using directive or an assembly reference?)

And its pointing to the line of code where I am instantiating the object of the class:

Line 84:         SMSAPP obj = new SMSAPP();

What exactly went wrong from the local version to the hosted version? Please help. Thanks.

What I learned:

Okay, so I haven't been able to run my project yet. But I learned few things which I would like to share- web applications and web sites are totally different things. Mine was a website, that's why the *.cs code's property did not have option to "Build Action" = "Compile". I converted my project from website to web application, and I could see the options being suggested in the answers here. However, no luck in the deployment.


回答1:


Right mouse click on the .cs file and select properties then check if the "Build action" is set to "Compile"




回答2:


Check your local App_Code folder, somewhere there you must have a class SMSAPP.

You must have forgotten to upload this file.




回答3:


Check property of your *.cs files in App_Code. They should have Build Action as Compile




回答4:


Check in IIS manager if your web app is configured to use the correct .NET version



来源:https://stackoverflow.com/questions/11446348/missing-a-using-directive-or-an-assembly-reference-error-upon-deploying-the-webs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!