我有一个带有一些自定义PCL库的Visual Studio 2013 Update 3解决方案,然后是一个包含Windows 8.1,WindowsPhone 8.1和共享位的UniversalApp项目。我正在尝试编译WindowsPhone项目。共享项目包含一些模型,ViewModel,实用程序类,图像和一些样式。
我不确定之前发生了什么变化,但现在我无法解决这个错误:
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()
我见过类似问题的帖子,但没有完全相同或有效的修复。我尝试过的事情:
<GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>
添加到项目文件<loadFromRemoteSources enabled="true" />
添加到devenv.exe.config文件答案 0 :(得分:0)
我也有同样的问题(对不起,不能评论 - 不够点),类似的设置: Win10 + VS2015
我已经把它缩小到我试图将MvvmCross合并到我的Win Phone 8.1项目中。我使用nuget来引入3.2.1 mvvmcross库。我已经检查了这些dll,但没有一个有Unblock按钮(好像它已经解锁了)。
如果我删除了dll引用,那么一切都可以正常工作。
此外,以管理员身份运行也无济于事。我明天将我的项目放到我的Win8.1框中,看看问题是否存在。
答案 1 :(得分:0)
我遇到了同样的问题,WS10 + VS2013 Update 4.
以管理员身份运行VS使我的问题消失了。
答案 2 :(得分:-2)
有点晚了,但如果以管理员身份运行VS2013,你应该没事(即它可以在我的机器上运行)。