类型或命名空间名称“LAD”找不到(是否缺少using指令或程序集引用?) [英] The type or namespace name 'LAD' could not be found (are you missing a using directive or an assembly reference?)

查看:134
本文介绍了类型或命名空间名称“LAD”找不到(是否缺少using指令或程序集引用?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有一个ASP Web应用程序在C#作为其后端,我试图得到运行,但网页(在我的箱子跑本地)给我的错误信息运行。现在,Web应用程序正在试图被引用命名空间使用LAD.CDD.NSJ;这是位于APP_ code文件夹中。

Hello I have an ASP web application runs on C# as its backend that I'm trying to get running but the webpage (ran locally on my box) gives me the error message. Now the namespace the webapp is trying to reference is "using LAD.CDD.NSJ;" which are located in the App_Code folder.

文件的名称是Common.cs,Email.cs,Data.cs和User.cs。

The name of the files are Common.cs, Email.cs, Data.cs, and User.cs.

他们都有code在命名空间调用LAD.CDD.NSJ。在previous程序员并没有使这些文件为DLL只顾埋头它作为一个cs文件。我试图使用这些文件的另一个项目,但保留收到这个错误消息。

They all have a namespace call LAD.CDD.NSJ within the code. The previous programmers didn't make those files into a dll and just kept it as a .cs file. I'm trying to use these files for another project but keep getting that error message.

推荐答案

APP_ code 文件夹是ASP.NET中的一个特殊的文件夹中。 ASP.NET将编译类型 APP_ code 进入这实际上是从你的Web应用程序组件分离的组件。这意味着,当你尝试使用这些类型从你的后端code(比如一个MVC控制器),它是无法解决的类型,因为这些类型将有一个生成操作设置为内容。与构建行动,该文件将不会被包含在主应用程序的编译。

The App_Code folder is a special folder in ASP.NET. ASP.NET will compile the types App_Code into an assembly which is actually separate from your web application assembly. This means, when you try and use those types from your backend code (e.g. an MVC controller), it is unable to resolve the type because those types will have a Build Action set to Content. With that build action, the file will not be included in the compilation of your main application.

我建议做,是沟使用 APP_ code 因为只修改构建行动编译不会停止ASP.NET动态编译一个 APP_ code 组装,所以你最终暧昧类型(例如,运行时不知道是否使用编译到主应用程序组件类型或动态APP_ code组装。

What I would recommend doing, is ditch using App_Code because simply changing the build action to Compile won't stop ASP.NET dynamically compiling an App_Code assembly, so you end up with ambiguous types (i.e., the runtime doesn't know whether to use the type compiled into your main application assembly, or the dynamic App_Code assembly.

移动这些文件到另一个位置,并设置生成操作(在属性),以编译

Move those files to another location, and set the Build Action (in Properties) to Compile.

这篇关于类型或命名空间名称“LAD”找不到(是否缺少using指令或程序集引用?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆