当项目位于映射网络驱动器上时,VS2010 中的 Silverlight 项目构建失败
我刚刚学习 Blend/Silverlight/VS2010/.net/etc。我有一个驻留在网络驱动器上的简单项目。当我告诉 VS2010 重建项目时,我收到以下错误消息:
------ 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 ==========
该项目不是从 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 驱动器上复制整个项目时,问题就消失了,但是,这个“解决方案”是相当不可取的。
此时,我真的不知道在不将项目移动到本地驱动器的情况下还有什么可以尝试解决问题。
非常感谢任何有助于解决问题的帮助。
约翰.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
VS2010 显示的错误消息会让任何人相信问题出在信任和安全性上,但事实是,无论允许多少网络驱动器的完全信任都无法解决问题。
解决办法是首先将项目移植到VS2008上,看看是否会遇到同样的问题。 VS2008 非常乐意运行该项目,没有任何抱怨。
然后我将 VS2008 项目(正在运行)转换为 VS2010。 VS2010 拒绝构建该项目,但这次错误消息不同,引用了“远程程序集”和 MSDN 上的链接,从而找到了解决方案。
真正的问题是 VS2010 将网络驱动器上的程序集视为“远程程序集”(就像从网站加载程序集一样。)Caspol 无法解决该问题(看起来应该有,但是,这可能是我的错,我不太熟悉使用 Caspol)。
为了结束这个长篇故事,错误消息中提供的链接是:
http://msdn.microsoft.com/en-us/library/dd409252(VS.100).aspx
按照该链接中的说明编辑“machine.config”后,我更改了
< ;runtime/>
to:项目成功构建并运行顺利。
约翰,感谢艾莉森和 CodeNaked 为帮助所做的努力
。
PS:如果 VS2010 最初显示“更好”的错误消息,那就太好了。相反,我必须将 VS2010 无法正常工作的项目移植到 VS2008(它可以正常工作),然后将该项目移植到 VS2010,在那里我得到了更好的错误消息,从而找到了解决方案。
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: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.
不确定这是否有帮助,但值得一试:如何允许我的 Visual Studio .NET 项目从网络位置运行?
Not sure if this will help but it's worth a shot: How Do I Allow my Visual Studio .NET Projects to Run from a Network Location?