类型或命名空间名称'DataAnnotations'不命名空间中存在'System.ComponentModel“ [英] The type or namespace name 'DataAnnotations' does not exist in the namespace 'System.ComponentModel'

查看:1323
本文介绍了类型或命名空间名称'DataAnnotations'不命名空间中存在'System.ComponentModel“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在任何关闭这个作为重复的 - 请注意它不是一个LINQ或其他数据源的问题,我已经看过其他计算器职位,没有一个是相同的。

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.

下面是我的问题:

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

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

default.aspx code

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%=returVar%>

Default.apsx.cs

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

and finally 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

My dev machine is: win 32 xp visual studio 2010 and Server running is Win 64bit 2008 R2 and IIS7.5.

那么,为什么当我在我的桌面上运行该code这个错误发生的历史它的工作原理就像HTTP火狐通过如下魅力:

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://本地主机:3117 / Default.aspx的测试= 0998989765432345

完全相同的code未能附加屏幕截图,有人可以告诉我为什么请提出解决方案。我想包括所有我的DLL从Solution Explorer中释放,即解决方案资源管理>参考> System.Core程序,System.Data这等...>所有设置复制本地=真。

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.

仍然没有运气。

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

Please note i cant install any extra components on the server and what ever i have to deploy has to be part of application.

推荐答案

如果别人凸点简单的解决方案到这种情况,这是我如何取得结果。

Easiest solution if anyone else bumps into this situation, here is how i achieved result

打开Visual Studio 2010,一旦其加载

open Visual studio 2010 once its loaded

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

open explorer -> goto > C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0

复制所需的System.ComponentModel.DataAnnotations.dll到项目中引用文件夹中选择参考,并在属性设置复制本地设置为true,一旦你发布它会在你的bin文件夹,并不会影响在所有的任何服务器是它的32倍或64位。

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.

希望它可以帮助别人。

这篇关于类型或命名空间名称'DataAnnotations'不命名空间中存在'System.ComponentModel“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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