0
votes

After Migrating a project from 2008 to 2012, while build or rebuild facing this issue.

Detailed Error as follows,

Error 2 The "GenerateResource" task failed unexpectedly. System.InvalidOperationException: The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag. at System.AppDomain.SetupDomainSecurity(AppDomainHandle appDomain, ObjectHandleOnStack appDomainEvidence, IntPtr creatorsSecurityDescriptor, Boolean publishAppDomain) at System.AppDomain.InitializeDomainSecurity(Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, Boolean generateDefaultEvidence, IntPtr parentSecurityDescriptor, Boolean publishAppDomain) at System.AppDomain.Setup(Object arg) at System.AppDomain.nCreateDomain(String friendlyName, AppDomainSetup setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor) at System.AppDomainManager.CreateDomainHelper(String friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo) at System.AppDomainManager.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo) at System.AppDomain.InternalCreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info) at System.AppDomain.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info) at Microsoft.Build.Tasks.GenerateResource.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

How do I fix this?

1

1 Answers

0
votes

The “GenerateResource” task failed unexpectedly. System.InvalidOperationException

(According to the error messages, they are all common errors. I could not give the most direct correct answer for this issue, I can only give you some troubleshootings. In order to avoid losing contact in the round-trip comments, I post those troubleshootings as answer instead of comments.)

To resolve this issue, please try following methods:

  • Add <NetFx40_LegacySecurityPolicy enabled="true"/> into the VS2012 DevEnv configuration file, you'll find it in C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe.config

  • Adding the following under the first property group in the Project file:

    <PropertyGroup>
        <GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>
    </ProjectGroup>
    
  • If you have app.config file in your project, please try to add following into it:

    <runtime>
      <NetFx40_LegacySecurityPolicy enabled="true"/>
      <legacyCasPolicy enabled="true"/>
    </runtime>
    
  • If above not helps you, please try to reinstall the Visual Studio 2012.

Hope this helps.