简体   繁体   English

使用XP Mode在Windows 7上构建Visual Studio 2010 Silverlight 4项目时出错

[英]Error building Visual Studio 2010 Silverlight 4 projects on Windows 7 with XP Mode

I installed Visual Studio 2010 Beta 2 in an XP Mode VM on Windows 7. Then I created a trivial Silverlight 4 (beta) project and tried to build it. 我在Windows 7上的XP模式VM中安装了Visual Studio 2010 Beta 2.然后我创建了一个简单的Silverlight 4(beta)项目并尝试构建它。 I get the following error: 我收到以下错误:

Error 1 The "ValidateXaml" task failed unexpectedly. 错误1“ValidateXaml”任务意外失败。 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. System.IO.FileLoadException:无法加载文件或程序集'file:// \\ tsclient \\ d \\ Users \\ me \\ Documents \\ Visual Studio 2010 \\ Projects \\ SilverlightApplication2 \\ SilverlightApplication2 \\ _dob \\ Debug \\ SilverlightApplication2.dll'或其中一个依赖。 Operation is not supported. 不支持操作。 (Exception from HRESULT: 0x80131515) (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. 文件名:'file:// \\ tsclient \\ d \\ Users \\ me \\ Documents \\ Visual Studio 2010 \\ Projects \\ SilverlightApplication2 \\ SilverlightApplication2 \\ obj \\ Debug \\ SilverlightApplication2.dll'---> System.NotSupportedException:尝试进行从网络位置加载程序集,这会导致程序集在以前版本的.NET Framework中被沙箱化。 This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. 此版本的.NET Framework默认情况下不启用CAS策略,因此此负载可能很危险。 If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. 如果此负载不是用于沙盒装配,请启用loadFromRemoteSources开关。 See http://go.microsoft.com/fwlink/?LinkId=155569 for more information. 有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkId=155569

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 ass 在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)System.Reflection.RuntimeAssembly.InternalLoadFrom(String)System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,Evidence assemblySecurity,StackCrawlMark&stackMark,Boolean forIntrospection,Boolean suppressSecurityChecks) assemblyFile,Evidence securityEvidence,Byte [] hashValue,AssemblyHashAlgorithm hashAlgorithm,Boolean forIntrospection,Boolean suppressSecurityChecks,StackCrawlMark&stackMark)at System.Reflection.Assembly.LoadFrom(String ass emblyFile) 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) emblyFile)在Microsoft.Silverlight.Build.Talks.ValidateXaml.XamlValidator.Execute(ITask任务)的Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute(ITask任务)在Microsoft.Silverlight.Build.Tasks.ValidateXaml.Execute ()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 )

I believe this is related to the fact that XP Mode redirects the My Documents folder to the host, turning it into a network share location, and some sort of CAS / security policy is being triggered. 我相信这与XP Mode将My Documents文件夹重定向到主机,将其转换为网络共享位置以及触发某种CAS /安全策略这一事实有关。

Anyone know how to fix it? 谁知道怎么修它?

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

Enabling loadFromRemoteSources is also explained on http://social.msdn.microsoft.com/Forums/en-US/webdevelopmentprerelease/thread/ea9b9cab-cbfd-496d-8a81-7b3dd06e8c23 along with another option; http://social.msdn.microsoft.com/Forums/en-US/webdevelopmentprerelease/thread/ea9b9cab-cbfd-496d-8a81-7b3dd06e8c23以及其他选项也解释了启用loadFromRemoteSources的问题。 set the environment variable COMPLUS_EnableLegacyCASPolicy. 设置环境变量COMPLUS_EnableLegacyCASPolicy。

Edit: (copy and paste from the above URL as the post got taken down) 编辑:(随着帖子被删除,从上面的URL复制并粘贴)

David DeWinter - MSFT (Wednesday, May 20, 2009 2:10 AM) David DeWinter - MSFT(2009年5月20日,星期三,上​​午2:10)

Caveat: I'm not on the security team but will attempt to answer this nonetheless... 警告:我不是安全团队,但会尝试回答这个问题......

What's happening here is that the build tasks for Silverlight are attempting to load an assembly that, in previous versions of the CLR, would classify it as a partial trust assembly based on its evidence (eg its zone) according to CAS policy. 这里发生的是Silverlight的构建任务正在尝试加载一个程序集,在以前版本的CLR中,它根据CAS策略根据其证据(例如其区域)将其分类为部分信任程序集。

In CLR 4.0, CAS policy is totally deprecated and is not even enabled by default. 在CLR 4.0中,CAS策略完全弃用,默认情况下甚至不启用。 Under the circumstances, though, it appears the CLR throws an Exception when what would be a partial trust load in CLR 2.0 is a full trust load in CLR 4.0. 但是,在这种情况下,当CLR 2.0中的部分信任负载是CLR 4.0中的完全信任负载时,CLR似乎会抛出异常。

The loadFromRemoteSources switch the Exception message refers to is in the runtime element under configuration and looks like this: loadFromRemoteSources切换引用的异常消息是在配置下的运行时元素中,如下所示:

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

This will not enable legacy CAS policy but will allow you (or, in this case, the build system) to load remote assemblies with the same permissions as the host AppDomain. 这不会启用旧版CAS策略,但允许您(或者,在本例中为构建系统)加载具有与主机AppDomain相同权限的远程程序集。 In this case it seems as though you could modify the configuration for the build system (which I assume in this case would be Visual Studio: %ProgramFiles%\\Microsoft Visual Studio 10.0\\Common7\\IDE\\devenv.exe.config) to enable this switch. 在这种情况下,似乎你可以修改构建系统的配置(我假设在这种情况下将是Visual Studio:%ProgramFiles%\\ Microsoft Visual Studio 10.0 \\ Common7 \\ IDE \\ devenv.exe.config)来启用此功能开关。

If you don't want to modify that configuration then you can set the environment variable COMPLUS_EnableLegacyCASPolicy to 1, which will enable CAS Policy that was present in CLR 2.0 and also allow Silverlight to load this task. 如果您不想修改该配置,则可以将环境变量COMPLUS_EnableLegacyCASPolicy设置为1,这将启用CLR 2.0中存在的CAS策略,并允许Silverlight加载此任务。

Hope that helps. 希望有所帮助。 David, Blog - http://blogs.rev-net.com/ddewinter/ Twitter - @ddewinter 大卫,博客 - http://blogs.rev-net.com/ddewinter/ Twitter - @ddewinter

It should work if you add <loadFromRemoteSources enabled="true"/> to devenv.exe.config . 如果将<loadFromRemoteSources enabled="true"/>devenv.exe.config,它应该可以工作。 More info at http://msdn.microsoft.com/en-us/library/dd409252%28VS.100%29.aspx 更多信息,请访问http://msdn.microsoft.com/en-us/library/dd409252%28VS.100%29.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM