GenerateResource”任務意外失敗的解決方法


錯誤描述:
System.InvalidOperationException: 配置有 NoSecurityChanges 標志的 AppDomainManager 修改了 AppDomain 的安全狀態。
   在 System.AppDomain.SetupDomainSecurity(AppDomainHandle appDomain, ObjectHandleOnStack appDomainEvidence, IntPtr creatorsSecurityDescriptor, Boolean publishAppDomain)
   在 System.AppDomain.InitializeDomainSecurity(Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, Boolean generateDefaultEvidence, IntPtr parentSecurityDescriptor, Boolean publishAppDomain)
   在 System.AppDomain.Setup(Object arg)
   在 System.AppDomain.nCreateDomain(String friendlyName, AppDomainSetup setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor)
   在 System.AppDomainManager.CreateDomainHelper(String friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo)
   在 System.AppDomainManager.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo)
   在 System.AppDomain.InternalCreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info)
   在 System.AppDomain.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info)
   在 Microsoft.Build.Tasks.GenerateResource.Execute()
   在 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   在 Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult) Genersoft.Platform.Task.UI

問題描述:

原因是.NET Framework 4 版已經棄用代碼訪問安全(CAS)策略。因此,如果顯式或隱式(通過其他類型和成員)調用過時的策略類型和成員,則可能遇到編譯警告和運行時異常。 
   參見MSDN:代碼訪問安全策略兼容性和遷移  http://msdn.microsoft.com/zh-cn/library/ee191568(VS.100).aspx

解決方法: 

if you have "The "ResolveComReference" task could not be instantiated from "Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". 

this error , most probably you've modified devenv.exe.config and added there

    <NetFx40_LegacySecurityPolicy enabled="true"/>

, am I right?

 

If this is the case, do this:

1) remove     <NetFx40_LegacySecurityPolicy enabled="true"/>  from devenv.exe.config

2) re-open VS,  compile your project. It will generate you all interops with no problems.

3) close VS, add     <NetFx40_LegacySecurityPolicy enabled="true"/>  again if you need it.

4) open VS, open your project.   Your references will be fine now.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM