当项目位于映射的网络驱动器上时,VS2010 中的 Silverlight 项目构建失败 [英] Silverlight project build fails in VS2010 when project is on a mapped network drive

查看:44
本文介绍了当项目位于映射的网络驱动器上时,VS2010 中的 Silverlight 项目构建失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在学习 Blend/Silverlight/VS2010/.net/etc.我有一个驻留在网络驱动器上的简单项目.当我告诉 VS2010 重建项目时,我收到以下错误消息:

<预>------ 重建全部开始:项目:MySilverlightApplication,配置:调试任何 CPU ------MySilverlightApplication -> H:\PRJ\VisualStudio\ExpressionBlend\Unleashed\MySilverLightApplication\MySilverlightApplication\Bin\Debug\MySilverlightApplication.dllC:\Program Files\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.Common.targets(214,9):错误:无法加载程序集file:///H:\PRJ\VisualStudio\ExpressionBlend\Unleashed\MySilverLightApplication\MySilverlightApplication\obj\Debug\MySilverlightApplication.dll.该程序集可能是从 Web 下载的.如果程序集是从 Web 下载的,它被 Windows 标记为 Web 文件,即使它驻留在本地计算机上.这可能会阻止它在您的项目中使用.您可以通过更改文件属性来更改此名称.仅取消阻止您信任的程序集.有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkId=179545.========== 全部重建:0 成功,1 失败,0 跳过 ==========

该项目不是从 Web 下载的(我使用 Blend 创建了它.)经过一番搜索,我猜测问题可能是由于 .net 安全设置.我发出了以下命令:

<预>C:\Program Files\Microsoft Visual Studio 10.0\VC>caspol -m -ag 1.3 -url "file://\\p4dc\h$\*" FullTrust

希望能解决问题.p4dc 是服务器机器的名称,h$ 是服务器上 h: 驱动器的管理共享,它依次映射到本地计算机上的驱动器号H"(\\p4dc\h$ 映射到 H在本地机器中).

这并没有解决问题.我不知道我的 caspol 命令是否正确(我不打算即时学习 caspol),这似乎是一个合理的尝试.当我在本地 C 驱动器上复制整个项目时,问题就消失了,但这种解决方案"是相当不受欢迎的.

此时,如果不将项目移动到本地驱动器,我真的不知道还有什么可以尝试解决问题.

非常感谢您提供解决方案的任何帮助.

约翰.

解决方案

VS2010 显示的错误消息会导致任何人相信问题出在信任和安全上,但事实并非如此,没有多少允许对网络驱动器的完全信任将解决问题.

解决办法是先把项目移植到VS2008看看会不会遇到同样的问题.VS2008 很高兴能毫无怨言地运行该项目.

然后我将 VS2008 项目(正在运行)转换为 VS2010.VS2010 拒绝构建项目,但这次的错误消息有所不同,指的是远程程序集"和 MSDN 上的链接,从而导致了解决方案.

真正的问题是 VS2010 将网络驱动器上的程序集视为远程程序集"(就像从网站加载程序集一样.)Caspol 无法解决该问题(似乎应该有但是,这可能是我的错,我不精通使用 Caspol).

为了结束这个长篇故事,错误消息中提供的链接是:

http://msdn.microsoft.com/en-us/library/dd409252(VS.100).aspx

按照该链接中的说明编辑machine.config"后,我将 更改为:

<loadFromRemoteSources enabled="true"/></运行时>

项目成功构建并顺利运行.

感谢 Alison 和 CodeNaked 的努力,

约翰.

PS:如果 VS2010 最初显示更好"的错误消息,那就太好了.相反,我不得不将 VS2010 非工作项目移植到它工作的 VS2008,然后将那个移植到 VS2010,在那里我得到了更好的错误消息,导致了解决方案.

I am just learning Blend/Silverlight/VS2010/.net/etc. I have a simple project that resides on a network drive. When I tell VS2010 to rebuild the project, I get the following error message:

------ Rebuild All started: Project: MySilverlightApplication, Configuration: Debug Any CPU ------
  MySilverlightApplication -> H:\PRJ\VisualStudio\ExpressionBlend\Unleashed\MySilverLightApplication\MySilverlightApplication\Bin\Debug\MySilverlightApplication.dll

C:\Program Files\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.Common.targets(214,9):
 error : Could not load the assembly 
         file:///H:\PRJ\VisualStudio\ExpressionBlend\Unleashed\MySilverLightApplication\MySilverlightApplication\obj\Debug\MySilverlightApplication.dll.
         This assembly may have been downloaded from the Web.  If an assembly has been downloaded from the Web,
         it is flagged by Windows as being a Web file, even if it resides on the local computer.
         This may prevent it from being used in your project. You can change this designation by changing the file properties.
         Only unblock assemblies that you trust. See http://go.microsoft.com/fwlink/?LinkId=179545 for more information.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

The project was not downloaded from the Web (I created it using Blend.) After doing some searching, I guessed the problem may be due to .net security settings. I issued the following command:

C:\Program Files\Microsoft Visual Studio 10.0\VC>caspol -m -ag 1.3 -url "file://\\p4dc\h$\*" FullTrust

in the hope that would solve the problem. p4dc is the name of the server machine, h$ is the administrative share for the h: drive on the server which in turn is mapped to the drive letter "H" on the local machine (\\p4dc\h$ is mapped to H in the local machine).

That did not solve the problem. I don't know if my caspol command is correct (I wasn't planning on learning caspol on the fly), it just seemed like a reasonable thing to try. The problem goes away when I make a copy of the entire project on the local C drive but, that "solution" is rather undesirable.

At this point, I don't really know what else to try to solve the problem without moving the project to a local drive.

Any help leading to a solution is much appreciated.

John.

解决方案

The error message displayed by VS2010 would lead anyone to believe the issue is with trust and security and it is BUT, no amount of allowing full trust on the network drive will solve the problem.

What lead to the solution was first to port the project to VS2008 to find out if it would encounter the same problem. VS2008 was perfectly happy to run the project without complaint.

Then I converted the VS2008 project (which was working) to VS2010. VS2010 refused to build the project but this time the error message was different, referring to "remote assemblies" and to a link on MSDN, which led to the solution.

The real problem is that VS2010 considers an assembly on a network drive a "remote assembly" (the same as if the assembly were being loaded from a web site.) Caspol was not able to solve that problem (it seems it should have but, it may be my fault, I am not well versed in using Caspol).

To end this long story, the link provided in the error message is:

http://msdn.microsoft.com/en-us/library/dd409252(VS.100).aspx

after following the instructions in that link to edit "machine.config", I changed <runtime/> to:

<runtime>
  <loadFromRemoteSources enabled="true"/>
</runtime>

the project built successfully and ran without a hitch.

Thank you to Alison and CodeNaked for their efforts to help,

John.

PS: it would have been rather nice if VS2010 had displayed the "better" error message initially. Instead, I had to port the VS2010 non working project to VS2008 where it worked and that one to VS2010 where I got the better error message that led to the solution.

这篇关于当项目位于映射的网络驱动器上时,VS2010 中的 Silverlight 项目构建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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