类型或命名空间名称'DataAnnotations'不命名空间中存在'System.ComponentModel“

编程入门 行业动态 更新时间:2024-10-28 10:21:33
本文介绍了类型或命名空间名称'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背后没有任何花哨的东西朴素简单的C#code,你可以从code见下文:

Its extremely simple app ASP 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 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“

本文发布于:2023-11-09 14:57:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572665.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:空间   名称   类型   System   DataAnnotations

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!