error MSB4018: The "GenerateResource" task failed unexpectedly  
Author Message
Jim Altrichter





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

I have a Smart Device application that is generating the following errror when I attempt to build. I would appreciate any feedback in how to debug this error, or what might be a typical cause of this problem.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1616,9): error MSB4018: The "GenerateResource" task failed unexpectedly.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1616,9): error MSB4018: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1616,9): error MSB4018: at Microsoft.Build.Shared.ExceptionHandling.RethrowUnlessFileIO(Exception e)

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1616,9): error MSB4018: at Microsoft.Build.Tasks.GenerateResource.NeedSeparateAppDomain()

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1616,9): error MSB4018: at Microsoft.Build.Tasks.GenerateResource.Execute()

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1616,9): error MSB4018: at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound)

Done building project "PromoScan.vbproj" -- FAILED.



Visual Studio1  
 
 
Kardath





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

Hi,

I have the same error message, it is generate after a conversion from a Visual Studio 2003 SmartDevice Project to a VS 2005 SmartDevice Project.

The conversion works fine, the first build to, but before the second build i want to open a form with the designer and after i attempt to build and i get this error...

Bye.


 
 
Jim Altrichter





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

That is intersting. I had converted this some of the projects in this solution from VS 2003, but it was quite a while ago. I had been able to build a release after the conversion and only now (some months later) have I intermittently encountered this error.

By any chance were you working with an Image Box conrol in your converted solution


 
 
Kardath





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

I don't use ImageBox Control in my solution. I've retest the conversion and befor open the Designer for my form i look in the InitializeComponent() method. and i find this :

this.BackColor = System.Drawing.Color.White;

this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));

this.ControlBox = false;

this.Controls.Add(this.labelMessage);

this.Controls.Add(this.buttonQuitter);

this.Controls.Add(this.buttonContinuer);

this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));

this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));

this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));

this.MaximizeBox = false;

this.MinimizeBox = false;

this.Text = resources.GetString("$this.Text");

this.Visible = ((bool)(resources.GetObject("$this.Visible")));

this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

this.Click += new System.EventHandler(this.FormInitialisation_Click);

this.Load += new System.EventHandler(this.FormInitialisation_Load);

After opening designer i have this :

//

// FormInitialisation

//

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;

resources.ApplyResources(this, "$this");

this.BackColor = System.Drawing.Color.White;

this.ControlBox = false;

this.Controls.Add(this.labelMessage);

this.Controls.Add(this.buttonQuitter);

this.Controls.Add(this.buttonContinuer);

this.MaximizeBox = false;

this.MinimizeBox = false;

this.Name = "FormInitialisation";

this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

this.Click += new System.EventHandler(this.FormInitialisation_Click);

this.Load += new System.EventHandler(this.FormInitialisation_Load);

this.ResumeLayout(false);

Some properties have disapear... and during the opening some popup appears to say that it is impossible to generate the code for Text or Visible Properties....

So strange.


 
 
Kardath





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

I'm working with Windows 2000 sp4 is it this the origin of the matter
 
 
Jim Altrichter





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

The development box I am using is Win Xp Sp 2
 
 
Kardath





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

the problem don't come from the OS. I asked the question to a MVP and he answer that he have the same problem. He said that we do to redraw all our form.... for the moment we don't find an other solution...
 
 
nhl66pens





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

I am getting this error also. We migrated a VS 2003 vb.net compact framework to VS 2005 and then converted it from cf 1.0 to cf 2.0. I checked everything in last friday to team foundation server and it was fine. I tried to rebuild the solution this morning and started getting this error. I have 23 projects in my solution with over 50 forms. I am not going to redraw every form. Is that solution a joke Does anyone have a real solution or is microsoft still working on this problem

Robert


 
 
Kardath





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

I've send a feedback to MS and my MVP contact to. I think that the redraw form is not a joke a soon as MS doesn't provide solution....

I'm happy to see that i'm not alone with this problem :p


 
 
mtsman





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

I find the same error when I added a resource file in VS8/Mobile 5 project properties. The problem is not associated with either the O/S or the conversion from an earlier VS project.

Create a new project (C# console application/Mobile 5 platform) and build the empty project--ok, this builds fine. Then go to the resources tab of the project properties and add a new resource. The project still builds ok with an empty resource added.

Next add a binary file resource (following the directions in Help for adding a new resource). Ok, once the resource is added it can be viewed by opening in the binary editor. Now try to build the project and it fails with the MSB4018 errors.

Go back to the solution view and right click on the resource, and delete it. Voila, the project builds just fine without the resource. This is a problem in the VS8 release that needs fixing NOW!


 
 
Kardath





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

i think that the error will generated by many way. Because i don't add ressource to my project file with the IDE. My Ressource are comming from RESX file added to project or resx file generated with a form.

With your answer, we know now that the problem come from the ressource gestion.

Hey MS you Need to read it and fix it!!! we have buy your release and have some project to drive!!!!

I posted the problems on the msdn feedback....


 
 
DanMoseley





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

Hi Jim,

We've had a few reports of this problem and we want to fix it. We believe it's probably a bug in the .NET framework, but we can't find it through inspecting their code. We can't progress further without a repro case in-house.

If anyone with this issue can zip up a solution that has this problem, that would be most helpful. I realize in many cases your code is confidential, but very often it's possible to pare down the code to the absolute minimum that still produces the issue, which hopefully doesn't include anything proprietary of yours.

. Once we have a way to repro ourselves, we should be able to figure this out.

Thanks

Dan

'this posting provided as-is, with no warranties'



 
 
Andrew Sims





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

I get this issue every couple of builds on a clean VS2005 Win Mobile project.

Did you get a zip of a solution, or are you still waiting for one

If I shut down and restart VS then the problem goes away for a while, until I play with a form, then it comes back ( well most of the time anyway )

I can mail my solution if it will help !


 
 
mtwal





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

I have found that I get this error every time I remove and add a resource. I am working on a dll that I use with my project and every time I remove the old dll and add the new one I have to close the dev environment and open again to get rid of the error.

Full Description is:

The "GenerateResource" task failed unexpectedly. System.InvalidOperationException: Collection was modified; enumeration may not execute. at Microsoft.Build.Shared.ExceptionHandling.RethrowUnlessFileIO(Exception e) at Microsoft.Build.Tasks.GenerateResource.NeedSeparateAppDomain() at Microsoft.Build.Taks.GenerateResource.Execute() at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode how ToExecute Task, Hashtable projectItemsAvailable To Task, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean&taskClassWasFound)

Hope that helps



 
 
Faisal Mohamood MSFT





PostPosted: Visual Studio MSBuild, error MSB4018: The "GenerateResource" task failed unexpectedly Top

Hi,

We know this problem and we are tracking this as an issue that needs fixing. In the mean time can you try this workaround and tell us if it resolves the problem for you

Edit your project file and add this to the first PropertyGroup:

<GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>

That should get rid of this error. Tell us what you find.

Faisal Mohamood | Program Manager | Visual Studio - MSBuild