Windows Application Migration - Visual Studio 2008 to 2010 - The "GenerateResource" task failed unexpectedly
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:
If anybody has got an update on this issue, Please help...
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.
You have tried the solution provided by PG but without luck. I will contact related engineer to check the state of the issue.
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact email@example.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!
- Proposed as answer by Cor LigthertMVP Friday, October 15, 2010 7:11 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...
- Created a C# Dll project
- Compiled and it works fine
- 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)
- Compiled and now it gives the following error.
The "GenerateResource" task failed unexpectedly.
System.InvalidOperationException: The security state of an
AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges
at System.AppDomain.SetupDomainSecurity(AppDomainHandle appDomain,
ObjectHandleOnStack appDomainEvidence, IntPtr creatorsSecurityDescriptor,
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,
at System.AppDomainManager.CreateDomainHelper(String friendlyName,
Evidence securityInfo, AppDomainSetup appDomainInfo)
at System.AppDomainManager.CreateDomain(String friendlyName, Evidence securityInfo,
at System.AppDomain.InternalCreateDomain(String friendlyName,
Evidence securityInfo, AppDomainSetup info)
at System.AppDomain.CreateDomain(String friendlyName, Evidence securityInfo,
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost,
TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket,
TaskExecutionMode howToExecuteTask, Boolean& taskResult) TestClassLibrary
I then tried...
- Adding the following to devenv.exe.config, Machine.config
- Adding the following under the first property group in the Project file.
Still no luck. Is it problem with my VS installation? I have already reinstalled and repaired it once.
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
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:
compilation still failing
5. Added teh following the .csproj<GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>
compilation still failing..
Any clues on what is going wrong?
- Edited by Sudheer Kumar Monday, October 18, 2010 5:44 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
If anybody has an update, please do post.
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.