UniversalApp Error "GenerateResource task failed unexpectedly" on Microsoft.Build.Tasks.v12.0.dll

4

I have a Visual Studio 2013 Update 3 solution with some custom PCL libraries and then a UniversalApp project which includes Windows 8.1, WindowsPhone 8.1 and the Shared bits. I'm trying to compile the WindowsPhone project. The Shared project contains some Models, ViewModels, utility classes, images and some styles.

I'm not sure what changed, as it was working before, but now I cannot get ride of this error:

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()

I have seen posts for similar issues, but none quite the same or with fixes that worked. Things I have tried:

  • Deleted .suo file
  • Added <GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies> to project file
  • Added <loadFromRemoteSources enabled="true" /> to devenv.exe.config file
  • Deleted the UniversalApp projects and recreated from scratch (copied in a some files though)
c#
.net
visual-studio-2013
windows-phone-8.1
win-universal-app
asked on Stack Overflow Nov 6, 2014 by Cood • edited Jan 19, 2016 by TylerH

3 Answers

0

I also have the same problem (sorry, can't comment - not enough points) with similar setup: Win10 + VS2015

I've narrowed it down to me trying to incorporate MvvmCross into my Win Phone 8.1 project. I'm using nuget to pull in the 3.2.1 mvvmcross libraries. I've inspected these dlls but none of them have an Unblock button (as if it's already unblocked).

If I remove the dll references, then everything works fine again.

Also, running as Administrator does not help. I will pull my project down tomorrow into my Win8.1 box and see if the problem exists.

answered on Stack Overflow Nov 19, 2014 by jgo
0

I had the same problem, WS10 + VS2013 Update 4.

Running VS as admin made the problem go away for me.

answered on Stack Overflow Dec 10, 2014 by Jonas
-2

A little late, but if run VS2013 as an administrator you should be fine (ie. it works on my machine).

answered on Stack Overflow Nov 16, 2014 by David Gordon

User contributions licensed under CC BY-SA 3.0