类型或命名空间名称“DataAnnotations”;命名空间“System.ComponentModel”中不存在;
在任何人将其作为重复项关闭之前 - 请注意它不是 linq 或其他数据源问题,并且我查看了其他 stackoverflow 帖子,没有一个是相同的。
这是我的问题:
它极其简单的应用程序 ASP.net,背后有 C# 代码,没有花哨的东西,就像你一样简单从下面的代码可以看到:
default.aspx 代码
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%=returVar%>
Default.apsx.cs
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
public string returVar;
protected void Page_Load(object sender, EventArgs e)
{
string n = String.Format("{0}", Request.Form["test"]);
//below we will place the code for ODP.net once the DB connectivity is resolved
if (n.Length == 16)
{
returVar = "Found";
}
else
{
returVar = "Not found";
}
}//Page_Load
}
和最后的 web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="false"/>
</system.web>
</configuration>
我的开发机器是: win 32 xp Visual Studio 2010 ,运行的服务器是 Win 64bit 2008 R2 和IIS7.5。
那么为什么当我在桌面上运行此代码时会发生此错误,它就像通过 firefox 使用 http 的魅力一样,如下所示:
http://localhost:3117/Default.aspx?test=0998989765432345
完全相同的代码失败并附带屏幕截图,有人可以告诉我为什么请提出解决方案。我尝试将解决方案资源管理器中的所有 DLL 包含到版本中,即解决方案资源管理器 >参考文献>> system.core、system.data 等...>>全部设置为 copy local = true。
还是没有运气。
请注意,我无法在服务器上安装任何额外的组件,并且我必须部署的内容都必须是应用程序的一部分。
Before anyone closes this as duplicate - please note its not a linq or other datasources issue and i have looked at other stackoverflow posts and none are same.
Here is my problem:
Its extremely simple app ASP.net with C# code behind no fancy stuff plain simple as you can see from code below:
default.aspx code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%=returVar%>
Default.apsx.cs
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
public string returVar;
protected void Page_Load(object sender, EventArgs e)
{
string n = String.Format("{0}", Request.Form["test"]);
//below we will place the code for ODP.net once the DB connectivity is resolved
if (n.Length == 16)
{
returVar = "Found";
}
else
{
returVar = "Not found";
}
}//Page_Load
}
and finally web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="false"/>
</system.web>
</configuration>
My dev machine is: win 32 xp visual studio 2010 and Server running is Win 64bit 2008 R2 and IIS7.5.
so why is this error occuring when i run this code on my desktop it works like a charm with http through firefox as below:
http://localhost:3117/Default.aspx?test=0998989765432345
exact same code fails with attached screen shot, can someone tell me why please propose the solution. I tried including ALL of my DLL from solution explorer to release i.e. Solution Explorer > References > system.core, system.data etc... > all set for copy local = true.
still no luck.
Please note i cant install any extra components on the server and what ever i have to deploy has to be part of application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果其他人遇到这种情况,最简单的解决方案是,以下是我
在加载打开资源管理器后打开 Visual Studio 2010 时
如何实现结果->转到> C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0
将所需的 System.ComponentModel.DataAnnotations.dll 复制到项目“References”文件夹中,选择该引用,然后在属性下将“copy local”设置为 true,然后执行一次您发布的它将位于您的 bin 文件夹中,并且不会对任何服务器(无论是 x32 还是 x64)产生影响。
希望它对其他人有帮助。
Easiest solution if anyone else bumps into this situation, here is how i achieved result
open Visual studio 2010 once its loaded
open explorer -> goto > C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0
copy the required System.ComponentModel.DataAnnotations.dll into your project "References" folder select that reference and under properties set "copy local" to true and once you publish it will be in your bin folder and wont impact at all on any server be it x32 or x64.
hope it helps anyone else.
您是否只安装了 .NET 4.0 的客户端配置文件版本?您可能需要完整版本。
Did you only install the client profile version of .NET 4.0 perhaps? You probably need the full version.