"GenerateResource" 任务意外失败 Windows 通用项目中的错误

The "GenerateResource" task failed unexpetedly Error in a Windows Universal project

我在构建我的应用程序时遇到以下错误。知道是什么原因造成的或如何解决吗?

错误 "GenerateResource" 任务意外失败。

System.IO.FileLoadException: 无法加载文件或程序集 'file:///C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Build.Tasks.Core\v4.0_14.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Tasks.Core.dll' 或其 dependencies.Operation 之一不受支持。 (HRESULT 异常:0x80131515)

文件名:'file:///C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Build.Tasks.Core\v4.0_14.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Tasks.Core.dll' ---> System.NotSupportedException:尝试从网络位置加载程序集,这会导致程序集在以前版本的 the.NET Framework.This .NET Framework 版本默认不启用 CAS 策略,因此此负载可能很危险。如果此加载不打算将程序集沙盒化,请启用 loadFromRemoteSources 开关。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkId=155569

在 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、布尔值 throwOnFileNotFound、布尔值 forIntrospection、布尔值 suppressSecurityChecks)

at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef、Evidence assemblySecurity、RuntimeAssembly reqAssembly、StackCrawlMark& stackMark、IntPtr pPrivHostBinder、布尔值 throwOnFileNotFound、布尔值 forIntrospection、布尔值 suppressSecurityChecks)

at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)

在 System.Reflection.Assembly.LoadFrom(字符串 assemblyFile,证据 securityEvidence)

at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)

在System.AppDomain.CreateInstanceFrom(字符串程序集文件,字符串类型名称)

在 System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyName, String typeName)

在 System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyName, String typeName)

在 Microsoft.Build.Tasks.GenerateResource.Execute()

在 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

在 Microsoft.Build.BackEnd.TaskBuilder.d__1.MoveNext() Nestle.WindowsPhone

这是 Windows10 的 9879 版本的一个错误。在 https://gist.github.com/davkean/2714b93d202b9875bbe1 找到的解决方法是手动修改 C:\Program Files (x86)\MSBuild。0\Bin\msbuild.config 并添加以下部分:

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