C# UniversalApp错误“;GenerateResource任务意外失败;在Microsoft.Build.Tasks.v12.0.dll上

C# UniversalApp错误“;GenerateResource任务意外失败;在Microsoft.Build.Tasks.v12.0.dll上,c#,.net,visual-studio-2013,windows-phone-8.1,win-universal-app,C#,.net,Visual Studio 2013,Windows Phone 8.1,Win Universal App,我有一个Visual Studio 2013 Update 3解决方案,其中包含一些自定义PCL库,然后是一个UniversalApp项目,其中包括Windows 8.1、Windows Phone 8.1和共享位。我正在尝试编译WindowsPhone项目。共享项目包含一些模型、视图模型、工具类、图像和一些样式 我不确定是什么改变了,因为它以前是工作的,但现在我无法克服这个错误: Error 8 The "GenerateResource" task failed unexpected

我有一个Visual Studio 2013 Update 3解决方案,其中包含一些自定义PCL库,然后是一个UniversalApp项目,其中包括Windows 8.1、Windows Phone 8.1和共享位。我正在尝试编译WindowsPhone项目。共享项目包含一些模型、视图模型、工具类、图像和一些样式

我不确定是什么改变了,因为它以前是工作的,但现在我无法克服这个错误:

Error   8   The "GenerateResource" task failed unexpectedly.
System.IO.FileLoadException: Could not load file or assembly 'file:///C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Build.Tasks.v12.0\v4.0_12.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Tasks.v12.0.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
File name: 'file:///C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Build.Tasks.v12.0\v4.0_12.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Tasks.v12.0.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, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, 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, Evidence securityEvidence)
   at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)
   at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName)
   at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyName, String typeName)
   at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyName, String typeName)
   at Microsoft.Build.Tasks.GenerateResource.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()
错误8“GenerateResource”任务意外失败。
System.IO.FileLoadException:无法加载文件或程序集的file:///C:\WINDOWS\Microsoft.Net\assembly\GAC\U MSIL\Microsoft.Build.Tasks.v12.0\v4.0\U 12.0.0.0\UUU b03f5f7f11d50a3a\Microsoft.Build.Tasks.v12.0.dll'或其依赖项之一。不支持此操作。(来自HRESULT的异常:0x8013155)
文件名:'file:///C:\WINDOWS\Microsoft.Net\assembly\GAC\U MSIL\Microsoft.Build.Tasks.v12.0\v4.0\U 12.0.0.0\UUU b03f5f7f11d50a3a\Microsoft.Build.Tasks.v12.0.dll'-->System.NotSupportedException:试图从网络位置加载程序集,这会导致该程序集在以前的.Net版本中被沙盒化框架默认情况下,.NET Framework的此版本不启用CAS策略,因此此负载可能很危险。如果此加载不是为了沙箱程序集,请启用loadFromRemoteSources开关。看见http://go.microsoft.com/fwlink/?LinkId=155569 了解更多信息。
在System.Reflection.RuntimeAssembly.\n加载(AssemblyName文件名、字符串代码基、证据assemblySecurity、RuntimeAssembly位置提示、StackScrawMark和stackMark、IntPtr pPrivHostBinder、Boolean throwOnFileNotFound、Boolean for Inspection、Boolean suppressSecurityChecks)
位于System.Reflection.RuntimeAssembly.nLoad(AssemblyName文件名、字符串代码基、证据assemblySecurity、RuntimeAssemblyLocationHint、StackScrawlMark和stackMark、IntPtr pPrivHostBinder、Boolean throwOnFileNotFound、Boolean For Inspection、Boolean suppressSecurityChecks)
位于System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,证据assemblySecurity,RuntimeAssembly reqAssembly,StackScrawMark&stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean For Inspection,Boolean suppressSecurityChecks)
位于System.Reflection.RuntimeAssembly.InternalLoadFrom(字符串汇编文件、证据安全性证据、字节[]哈希值、AssemblyHashAlgorithm哈希算法、Boolean ForInspection、Boolean suppressSecurityChecks、StackScrawMark和stackMark)
位于System.Reflection.Assembly.LoadFrom(字符串assemblyFile,证据securityEvidence)
位于System.Activator.CreateInstanceFromInternal(字符串汇编文件、字符串类型名、布尔型ignoreCase、BindingFlags bindingAttr、Binder Binder、对象[]args、CultureInfo区域性、对象[]ActivationAttribute、证据安全信息)
位于System.AppDomain.CreateInstanceFrom(字符串汇编文件,字符串类型名)
位于System.AppDomain.CreateInstanceFromAndUnwrap(字符串assemblyName,字符串typeName)
位于System.AppDomain.CreateInstanceFromAndUnwrap(字符串assemblyName,字符串typeName)
在Microsoft.Build.Tasks.GenerateResource.Execute()中
位于Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ItaskeExecutionHost.Execute()
在Microsoft.Build.BackEnd.TaskBuilder.d_u20.MoveNext()中
我看到过类似问题的帖子,但没有一篇完全相同,或者有修复效果。我尝试过的事情:

  • 已删除.suo文件
  • true
    添加到项目文件中
  • 在devenv.exe.config文件中添加了
  • 删除了UniversalApp项目并从头开始重新创建(但在一些文件中复制)

有点晚,但如果以管理员身份运行VS2013,您应该不会有问题(即它在我的机器上工作)。

我也有类似设置的问题(抱歉,无法评论-没有足够的分数): Win10+VS2015

我把范围缩小到我试图将MvvmCross纳入我的Win Phone 8.1项目。我正在使用nuget拉入3.2.1 mvvmcross库。我已经检查过这些DLL,但没有一个有解锁按钮(好像它已经解锁了)

如果我删除dll引用,那么一切都会恢复正常


此外,以管理员身份运行也没有帮助。明天我将把我的项目拉到我的Win8.1框中,看看问题是否存在。

我也有同样的问题,WS10+VS2013更新4


以管理员的身份运行VS使问题得以解决

我也有同样的问题,除了运行工具的操作系统(现在是Windows10TP)之外,我想不出自上次工作以来还有什么变化。你也在使用#Win10吗?我也在运行windows10tp,我只是想这可能也是问题所在。嗯,我很喜欢Win10,但这可能是回到8.1的原因,除非任何人都能想到解决办法。我刚刚尝试的另一个方法是全新安装Windows 10 TP Build 9879,但同样的问题@卢西安索,它现在在为我工作。。。前几天,它刚刚开始编译,然后我做了一个干净的解决方案,在关闭并重新打开VS后,错误再次出现。测试相同的清理、编译(不工作)、重新启动VS,然后再次清除错误。重新启动VS以前不工作,所以我不知道为什么它现在工作。不幸的是,以管理员身份运行并没有什么帮助。我在Win10TP上的VS2015预览版中遇到了同样的错误。同样的文件。(尽管文件夹名称中有v4.0_14)。但仅适用于Windows Phone项目。