简体   繁体   English

部署网站时缺少using指令或程序集引用错误

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

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). 我有一个网站,* .cs文件位于App_Code文件夹中(在我的项目中添加一个类项目,VS2010建议我创建这个文件夹)。 I have a default.aspx.cs file which makes use of this class. 我有一个default.aspx.cs文件,它使用了这个类。 It runs without any error when I run on VS2010. 当我在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". 我是一个网站,这就是为什么* .cs代码的属性没有“Build Action”=“Compile”的选项。 I converted my project from website to web application, and I could see the options being suggested in the answers here. 我将我的项目从网站转换为Web应用程序,我可以在这里看到答案中建议的选项。 However, no luck in the deployment. 但是,在部署中没有运气。

Right mouse click on the .cs file and select properties then check if the "Build action" is set to "Compile" 右键单击.cs文件并选择属性,然后检查"Build action"是否设置为“编译”

建立行动

Check your local App_Code folder, somewhere there you must have a class SMSAPP . 检查您的本地App_Code文件夹,在那里您必须有一个类SMSAPP

You must have forgotten to upload this file. 您必须忘记上传此文件。

Check property of your *.cs files in App_Code. 在App_Code中检查* .cs文件的属性。 They should have Build Action as Compile 他们应该将Build Action作为Compile

如果您的Web应用程序配置为使用正确的.NET版本,请检入IIS管理器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM