2012-02-06 203 views
2

存在任何关闭此为重复之前 - 请注意,它不是一个LINQ或其他数据源的问题,我已经看了其它计算器职位,没有一个是相同。类型或命名空间名称DataAnnotations'不存在命名空间“System.ComponentModel”

这里是我的问题:

的Default.aspx代码:

Error Screen Shot

它非常简单的应用程序ASP.net背后没有任何花哨的东西朴素简单的C#代码,你可以从下面的代码见

<%@ 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> 

我的dev的机器是:赢得32 XP Visual Studio 2010和服务器运行的是64位赢得2008 R2和IIS7.5。

那么,为什么这个错误发生的历史,当我在我的桌面上运行此代码它就像一个魅力与HTTP通过火狐如下:

http://localhost:3117/Default.aspx?test=0998989765432345

完全相同的代码将失败,并附加截屏,能有人告诉我为什么请提出解决方案。我尝试在解决方案资源管理器中包含所有我的DLL,即解决方案资源管理器>参考> system.core,system.data等...>所有设置为copy local = true。

仍然没有运气。

请注意,我不能在服务器和我有部署什么都必须是应用程序的一部分上安装任何额外的组件。

+0

检查这个环节,这可能是有益的 [点击此链接] [1] [1]:HTTP://计算器。com/questions/10174420/why-cant -i-reference-system-componentmodel-dataannotations/22644777#22644777 – 2014-03-25 19:49:47

回答

4

最简单的解决方案,如果其他人碰到这种情况,这是我如何实现结果

打开Visual Studio 2010,一旦其加载

打开资源管理器 - >转到> C:\ Program Files文件\参考大会\ Microsoft \ Framework.NETFramework \ v4.0

将所需的System.ComponentModel.DataAnnotations.dll复制到您的项目“References”文件夹中选择该引用并在属性下将“copy local”设置为true,一旦您发布它,将会在您的bin文件夹中,并且不会影响任何服务器,无论它是x32还是x64。

希望它可以帮助任何人。

0

您是否只安装.NET 4.0的客户端配置文件版本?您可能需要完整版本。

+0

请注意我无法在服务器上安装任何额外的组件,并且我必须部署的必须是应用程序的一部分。 – codejunkie 2012-02-06 18:37:57

相关问题