2009-12-01 62 views
3

我在Windows 7的XP模式VM中安装了Visual Studio 2010 Beta 2。然后创建了一个普通的Silverlight 4(测试版)项目并尝试构建它。我收到以下错误:在Windows 7上使用XP模式构建Visual Studio 2010 Silverlight 4项目时出错

Error 1 The "ValidateXaml" task failed unexpectedly. System.IO.FileLoadException: Could not load file or assembly 'file://\tsclient\d\Users\me\Documents\Visual Studio 2010\Projects\SilverlightApplication2\SilverlightApplication2\obj\Debug\SilverlightApplication2.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

File name: 'file://\tsclient\d\Users\me\Documents\Visual Studio 2010\Projects\SilverlightApplication2\SilverlightApplication2\obj\Debug\SilverlightApplication2.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) at System.Reflection.Assembly.LoadFrom(String assemblyFile) at Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute(ITask task) at Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute(ITask task) at Microsoft.Silverlight.Build.Tasks.ValidateXaml.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)

我相信这是关系到XP模式重定向My Documents文件夹到主机,把它变成一个网络共享位置,和某种CAS /安全策略的是事实被触发。

任何人都知道如何解决它?

回答

4

您是否在配置文件中添加了<loadFromRemoteSources enabled="true"/>

+2

*哪个*配置文件? – 2009-12-01 20:59:46

+0

凯文,你看到我的评论? - > devenv.exe.config – Fabrice 2010-04-13 12:04:28

3

它应该工作,如果您将<loadFromRemoteSources enabled="true"/>添加到devenv.exe.config。 更多信息在http://msdn.microsoft.com/en-us/library/dd409252%28VS.100%29.aspx

+0

我真的不喜欢微软,因为它需要修补第三方应用程序的配置文件,以便我们可以假装网络共享就像本地驱动器一样。 – 2010-03-01 06:42:05

+0

在这里没有这样的文件:( – jayarjo 2011-01-23 09:49:42

4

启用loadFromRemoteSources也在http://social.msdn.microsoft.com/Forums/en-US/webdevelopmentprerelease/thread/ea9b9cab-cbfd-496d-8a81-7b3dd06e8c23上与其他选项一起解释;设置环境变量COMPLUS_EnableLegacyCASPolicy。

编辑:(复制并从上面的URL粘贴视后得到了取下来)

大卫DeWinter - MSFT(星期三,2009年5月20日2:10)

警告:我虽然不在安全团队,但会尝试回答这个问题......

这里发生的事情是,Silverlight的构建任务试图加载一个程序集,该程序在以前版本的CLR中会将其归类为根据CAS政策,根据其证据(例如其区域)开展部分信托大会。

在CLR 4.0中,CAS策略完全不推荐使用,默认情况下甚至不启用。但是,在这种情况下,CLR 2.0中的部分信任负载是CLR 4.0中的完全信任负载时,CLR会抛出异常。

的loadFromRemoteSources切换异常消息是指在运行时元素的配置,看起来像这样:

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

这不会使传统的CAS政策,但将允许您(或者,在这种情况下,构建系统)以与主机AppDomain相同的权限加载远程程序集。在这种情况下,您似乎可以修改构建系统的配置(我假设在这种情况下是Visual Studio:%ProgramFiles%\ Microsoft Visual Studio 10.0 \ Common7 \ IDE \ devenv.exe.config)以启用此功能开关。

如果您不想修改该配置,则可以将环境变量COMPLUS_EnableLegacyCASPolicy设置为1,这将启用CLR 2.0中存在的CAS策略,并允许Silverlight加载此任务。

希望有所帮助。 David,博客 - http://blogs.rev-net.com/ddewinter/ Twitter - @dwinwinter

+0

链接是(现在)损坏 – 2011-09-07 09:02:31

+1

把上面的URL放到[link] http://www.archive.org/中似乎现在可以工作了 要做loadFromRemoteSources关闭VS 2010 ,然后打开%ProgramFiles%\ Microsoft Visual Studio 10.0 \ Common7 \ IDE \ devenv.exe.config文件并添加loadFromRemoteSources元素,如下所示: ShawnFeatherly 2011-09-07 20:09:19

+0

@Shawn感谢您的评论。 – 0x4f3759df 2013-01-20 17:36:23

相关问题