在VS2010中添加引用悄然失败 [英] Add reference in VS2010 fails quietly

查看:190
本文介绍了在VS2010中添加引用悄然失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VS2008 Silverlight 3.0示例(来自Pro Silverlight 3.0书籍示例),我已经升级到VS2010和Silverlight 5.0

构建失败,并显示以下内容:
Pro Silverlight 3 \ Chapter16 \ DataBinding \ DataBinding \ Product.cs(11,29):错误CS0234:类型或名称空间名称"DataAnnotations"在名称空间"System.ComponentModel"中不存在(您是否缺少组装参考?)
所以我将引用添加到C:\ Program Files(x86)\ Microsoft SDKs \ Silverlight \ v5.0 \ Libraries \ Client \ System.ComponentModel.DataAnnotations.dll

(通过浏览器或.Net选项卡)

当我单击确定"按钮时,对话框接受此设置.
但是,构建仍然会失败(并且使用System.ComponentModel.DataAnnotations; Products.cs文件中的行仍指示错误:2类型或名称空间DataAnnotations在名称空间System.ComponentModel中不存在)

我的机器上没有Silverlight 3-只有Silverlight 5

帮助!

10Pints

I have a VS2008 Silverlight 3.0 sample (from Pro Silverlight 3.0 book examples) which I have upgraded to VS2010 and Silverlight 5.0

The build fails with:
Pro Silverlight 3\Chapter16\DataBinding\DataBinding\Product.cs(11,29): error CS0234: The type or namespace name ''DataAnnotations'' does not exist in the namespace ''System.ComponentModel'' (are you missing an assembly reference?)
So i add a ref to C:\Program Files (x86)\Microsoft SDKs\Silverlight\v5.0\Libraries\Client\System.ComponentModel.DataAnnotations.dll

(either by browse or the .Net tab)

the dialog accepts this when i click the OK button.
However the build still fails ( and the using System.ComponentModel.DataAnnotations; line in the Products.cs file still indicates an error: 2 the type or namespace DataAnnotations does not exist in the namespace System.ComponentModel)

I do not have silverlight 3 on my machine - only silverlight 5

help!

10Pints

推荐答案

首先,您不应该以这种方式添加此程序集.该程序集随.NET Framework(免费重新分发)安装一起提供,并放置在 Global Assembly Cache (GAC), http://en.wikipedia.org/wiki/Global_Assembly_Cache [ ^ ].

因此,您应该使用添加引用"窗口的".NET"选项卡添加对此程序集的引用. (由于某些原因,浏览"选项卡显示为最后一个选项卡-相对很少使用;最常用的选项卡应为".NET"和项目".)

请参阅 http://msdn.microsoft.com/en-us/library/system. componentmodel.dataannotations.aspx [ ^ ].

当然,不要忘记使用以下两者之一:1)具有名称空间的标准类型名称; 2)或using 别名指令; 3)或简单的using指令:
http://msdn.microsoft.com/en-us/library/sf0df423%28v = vs.100%29.aspx [ ^ ].

—SA
First of all, you should not add this assembly in this way. This assembly comes with .NET Framework (freely redistributed) installation and is placed in Global Assembly Cache (GAC), http://en.wikipedia.org/wiki/Global_Assembly_Cache[^].

So, you should add a reference to this assembly using the tab ".NET" of the "Add Reference" window. (The tab "Browse" is shown as the last one for are reason — is it used relatively rarely; most used tabs should be ".NET" and "Project".)

Please see http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.aspx[^].

And of course don''t forget to use either 1) fully-qualified type names, with the name space; 2) or using alias directive; 3) or simple using directive:
http://msdn.microsoft.com/en-us/library/sf0df423%28v=vs.100%29.aspx[^].

—SA


这篇关于在VS2010中添加引用悄然失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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