none
Windows Application Migration - Visual Studio 2008 to 2010 - The "GenerateResource" task failed unexpectedly

    Question

  • I hav a windows forms application built using VS 2008 which I am trying to migrate to VS 2010 & .net 4.0.

    I got this nasty bug and found that it is due to the embedded images in the resource file.

    <!-- [if gte mso 10]> <mce:style>

    The "GenerateResource" task failed unexpectedly. System.InvalidOperationException: The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag.

    I tried the following solutions suggested in various forums.

    I added the < NetFx40_LegacySecurityPolicy enabled = " true " /> line to the <runtime> group in the devenv.exe.config file. I also tried the <GenerateResourceNeverLockTypeAssemblies>trugee</GenerateResourceNeverLockTypeAssemblies> work around and also running devenv /clean and devenv setup.

    I still get the compilation error.

    The depth of this problem can be found by looking at this thread:

    http://www.go4answers.com/Example/error-msb4018-generateresource-task-25286.aspx

    If anybody has got an update on this issue, Please help...

    Thanks!

    Thursday, October 14, 2010 3:12 AM

All replies

  • Hi Sudheer,

     

    I have found a duplicate thread post by you. Since this thread contains more detail information than that thread, I will delete that thread and focus on this one. Please don’t cross post next time. Thank you for your understanding.

     

    After some researches, I found it is a known hot issue on MS Connect.

    http://connect.microsoft.com/VisualStudio/feedback/details/94183/the-generateresource-task-failed-unexpectedly

    You have tried the solution provided by PG but without luck. I will contact related engineer to check the state of the issue.

     

    Sincerely,

    Kira Qian

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework!
    Friday, October 15, 2010 7:01 AM
  • Hi Kira, Thanks for looking in to this issue

    I posted the same issue another thread after seeing no response to this thread a day. But I will surely take care of it in future.

    The re-post I did had more simple steps to re-produce the issue.

    I see that the link you provided is related to this since it is mostly related to VS 2005. The exception and stack trace in my case is totally different, though the error message is the same. I have added my comment over there too.

    Here I am providing the simple steps to reproduce the issue.

    -------------------------------------------STEPS TO REPRODUCE---------------------------------------

    I installed VS 2010 on my Win XP SP3 machine and...

    1. Created a C# Dll project
    2. Compiled and it works fine
    3. Added a resx file to the project and added a few images to it(it doesn't matter whether you add a gif or png)
    4. Compiled and now it gives the following error.
    --------------------------Compile Error-----------------------------
    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.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost,
     TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket,
    TaskExecutionMode howToExecuteTask, Boolean& taskResult) TestClassLibrary

    I then tried...

    1. Adding the following to devenv.exe.config, Machine.config
    <runtime>
    <NetFx40_LegacySecurityPolicy enabled="true"/>
    </runtime>
    1. Adding the following under the first property group in the Project file.
     <PropertyGroup>
    <GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>
    </ProjectGroup>

    Still no luck. Is it problem with my VS installation? I have already reinstalled and repaired it once.

    Friday, October 15, 2010 12:59 PM
  • Here is another observation.

    I think the Visual Studio was downloaded from the MSDN subscription.

    I find the version of VS 2010 is : 10.0.30319.1 RTMRel

    Looks like it is the final run time version and not the release version.

     

    As per suggestion from a blog (http://blogs.msdn.com/b/shawnfa/archive/2009/06/12/temporarily-re-enabling-cas-policy-during-migration.aspx), I tried the following in the devenv.exe.config

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

    but still it didn't work.

     

    Another thing I tried is to create a simple windows forms application.

    I followed the same steps.

    1. Add a resource file (It compiles)

    2. Add an image (.gif) to the resource file (on compiling, it starts giving the above error.)

    3. I added a new configuration file and added the above mentioned setting (still the same error)

    4. I changed the config setting to have this:

    <NetFx40_LegacySecurityPolicy enabled="true"/>

    compilation still failing

    5. Added teh following the .csproj

    <GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>

    compilation still failing..

     

    Any clues on what is going wrong?

     

    Monday, October 18, 2010 3:19 PM
  • Can anybody please confirm whether I am running the latest release version or not?
    Monday, October 18, 2010 5:42 PM
  • Tried the migration of a Windows Server 2008 machine and ended up getting the same exception.

    We gave up the idea of migrating to EF 4.0 due to this issue and also due to the following change in behavior in EF 4.0

     

    https://connect.microsoft.com/VisualStudio/feedback/details/534675/ef4-include-method-returns-different-results-than-ef1-include?wa=wsignin1.0

    If anybody has an update, please do post.


    Wednesday, October 27, 2010 9:15 AM
  • Hi,

    Can you provide the project that is failing to build for a repro? bill_bo8@hotmail.com


    bill boyce
    Monday, November 01, 2010 5:06 PM
    Moderator
  • Hi Bill,

    I have sent you a sample project that reproduces the issue I am having.

    Thanks!

    Monday, November 08, 2010 1:59 PM
  • Thanks, got it...checking with a colleague on this
    bill boyce
    Monday, November 08, 2010 7:16 PM
    Moderator
  • Hi,

    In checking on this, would not be able to repro there would need to complete debuggign on your system.

    My suggestion is to see about what options to check out first, here is some info for more in depth level into the problems through support.

    There are various support options such as advisory and per issue. Please visit the below link to see the various paid

    support options that are available to better meet your needs.

    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone


    bill boyce
    Wednesday, November 10, 2010 1:14 AM
    Moderator