none
error MSB4018: The "GenerateResource" task failed unexpectedly

    Question

  • 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.

    Tuesday, June 20, 2006 9:46 PM

Answers

  • 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

    Sunday, July 16, 2006 6:35 PM
  • Faisal,

    u r a champion.It works for me.

    Thanks very much.

    Cheers

    Chandra

     

     

    Monday, July 17, 2006 9:21 PM

All replies

  • 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.

    Wednesday, June 21, 2006 1:29 PM
  • 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?

    Wednesday, June 21, 2006 6:40 PM
  • 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.

    Thursday, June 22, 2006 8:52 AM
  • I'm working with Windows 2000 sp4 is it this the origin of the matter?
    Thursday, June 22, 2006 10:20 AM
  • The development box I am using is Win Xp Sp 2
    Friday, June 23, 2006 8:26 PM
  • 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...
    Saturday, June 24, 2006 8:23 AM
  • 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

    Tuesday, June 27, 2006 2:00 PM
  • 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

    Tuesday, June 27, 2006 2:16 PM
  • 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!

    Tuesday, June 27, 2006 5:44 PM
  • 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....

    Tuesday, June 27, 2006 6:37 PM
  • 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.

    Ideally, you could attach it to the existing feedback report on the product feedback center, or if that doesn't work, send the zip to msbuild@microsoft.com. 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'

    Tuesday, July 04, 2006 3:35 PM
  • 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 !

     

    Monday, July 10, 2006 12:36 PM
  • 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

    Friday, July 14, 2006 9:05 PM
  • 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

    Sunday, July 16, 2006 6:35 PM
  • Faisal,

    u r a champion.It works for me.

    Thanks very much.

    Cheers

    Chandra

     

     

    Monday, July 17, 2006 9:21 PM
  • Faisal,

    thanks for the work around, it got rid of the error when removing and adding a dll.

     

    Matt

    Wednesday, July 19, 2006 4:31 PM
  • Faisal,

     

    You  are my hero!!!!

    Thursday, July 20, 2006 8:03 PM
  • I had exactly the same error message here, but our workaround was a little different. We used a (24 bit) PNG picture for a splash screen for our application, and the error started occurring. After replacing it with a GIF the error seemed to dissapear.
    Friday, July 21, 2006 8:50 AM
  • I recently ported a project from .NET CF 1.0 to .NET CF 2.0.  Now, any time I update a resource file I get this error.  I just received a new set of updated graphics to be loaded into existing picture box controls on some forms used in my ported project.  So, as a work-around, I  have been diffing the before and after resource and CS files for the the forms that have been affected, and then manually editing both to minimize changes generated by for form editor.

    Here is a diff with the graphics blob removed:

      <?xml version="1.0" encoding="utf-8"?>
       <root>
         <!--
           Microsoft ResX Schema
          
    <      Version 1.0
    ->     Version 2.0
          
           The primary goals of this format is to allow a simple XML format
           that is mostly human readable. The generation and parsing of the
           various data types are done through the TypeConverter classes
           associated with the data types.
          
           Example:
          
           ... ado.net/XML headers & schema ...
           <resheader name="resmimetype">text/microsoft-resx</resheader>
    <      <resheader name="version">1.0</resheader>
    ->     <resheader name="version">2.0</resheader>
           <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
           <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <      <data name="Name1">this is my long string</data>
    ->     <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
           <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
           <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
    <          [base64 mime encoded serialized .NET Framework object]
    ->         <value>[base64 mime encoded serialized .NET Framework object]</value>
           </data>
           <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <          [base64 mime encoded string representing a byte array form of the .NET Framework object]
    ->         <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
    ->         <comment>This is a comment</comment>
           </data>
                      
           There are any number of "resheader" rows that contain simple
           name/value pairs.
          
           Each data row contains a name, and value. The row also contains a
           type or mimetype. Type corresponds to a .NET class that support
           text/value conversion through the TypeConverter architecture.
           Classes that don't support this are serialized and stored with the
           mimetype set.
          
    <      The mimetype is used forserialized objects, and tells the
    ->     The mimetype is used for serialized objects, and tells the
           ResXResourceReader how to depersist the object. This is currently not
           extensible. For a given mimetype the value must be set accordingly:
          
           Note - application/x-microsoft.net.object.binary.base64 is the format
           that the ResXResourceWriter will generate, however the reader can
           read any of the formats listed below.
          
           mimetype: application/x-microsoft.net.object.binary.base64
           value   : The object must be serialized with
    <              : System.Serialization.Formatters.Binary.BinaryFormatter
    ->             : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
                   : and then encoded with base64 encoding.
          
           mimetype: application/x-microsoft.net.object.soap.base64
           value   : The object must be serialized with
                   : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
                   : and then encoded with base64 encoding.
      
           mimetype: application/x-microsoft.net.object.bytearray.base64
           value   : The object must be serialized into a byte array
                   : using a System.ComponentModel.TypeConverter
                   : and then encoded with base64 encoding.
           -->
         <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    ->     <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
           <xsd:element name="root" msdata:IsDataSet="true">
             <xsd:complexType>
               <xsd:choice maxOccurs="unbounded">
    ->           <xsd:element name="metadata">
    ->             <xsd:complexType>
    ->               <xsd:sequence>
    ->                 <xsd:element name="value" type="xsd:string" minOccurs="0" />
    ->               </xsd:sequence>
    ->               <xsd:attribute name="name" use="required" type="xsd:string" />
    ->               <xsd:attribute name="type" type="xsd:string" />
    ->               <xsd:attribute name="mimetype" type="xsd:string" />
    ->               <xsd:attribute ref="xml:space" />
    ->             </xsd:complexType>
    ->           </xsd:element>
    ->           <xsd:element name="assembly">
    ->             <xsd:complexType>
    ->               <xsd:attribute name="alias" type="xsd:string" />
    ->               <xsd:attribute name="name" type="xsd:string" />
    ->             </xsd:complexType>
    ->           </xsd:element>
                 <xsd:element name="data">
                   <xsd:complexType>
                     <xsd:sequence>
                       <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                       <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
                     </xsd:sequence>
    <                <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
    ->               <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
                     <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
                     <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
    ->               <xsd:attribute ref="xml:space" />
                   </xsd:complexType>
                 </xsd:element>
                 <xsd:element name="resheader">
                   <xsd:complexType>
                     <xsd:sequence>
                       <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                     </xsd:sequence>
                     <xsd:attribute name="name" type="xsd:string" use="required" />
                   </xsd:complexType>
                 </xsd:element>
               </xsd:choice>
             </xsd:complexType>
           </xsd:element>
         </xsd:schema>
         <resheader name="resmimetype">
           <value>text/microsoft-resx</value>
         </resheader>
         <resheader name="version">
    <      <value>1.0</value>
    ->     <value>2.0</value>
         </resheader>
         <resheader name="reader">
    <      <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    ->     <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
         </resheader>
         <resheader name="writer">
    <      <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    ->     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
         </resheader>
    <    <data name="mainMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    ->   <metadata name="mainMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
           <value>17, 17</value>
    <    </data>
    <    <data name="pictureBox.Image" type="System.Drawing.Bitmap, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.bytearray.base64">
    ->   </metadata>
    ->   <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    ->   <data name="pictureBox.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
           <value>

       </value>
         </data>
    <    <data name="$this.FormFactorShadowProperty">
    <      <value xml:space="preserve">SMARTPHONE_2003_QVGA</value>
    <    </data>
    <    <data name="$this.Skin" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    ->   <metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
    ->     <value>Smartphone QVGA</value>
    ->   </metadata>
    ->   <metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
           <value>True</value>
    <    </data>
    ->   </metadata>
    ->   <metadata name="$this.UndoSkinCounterProperty" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    ->     <value>1</value>
    ->   </metadata>
    ->   <metadata name="$this.FormFactor" xml:space="preserve">
    ->     <value>Smartphone QVGA</value>
    ->   </metadata>
       </root>

    Thursday, August 24, 2006 1:18 PM
  • Michael,

    Does the workaround from Faisal earlier in this thread fix it?

    Dan

    Thursday, August 24, 2006 3:10 PM
  •  Super Solution !!!

    We have Win Mobile5/Phone as the target platforms and are writing apps from scratch, and this was really starting to become a pain in the A***.

    Since I put this little gem in place, I can hack anywhere in the code, add and remove/update forms etc, with all sorts of controls and third party components in them, and I've not had a lock out for a week now !

    Thanks very much !!

    Tuesday, September 12, 2006 3:11 PM
  • It doesn't work.

    I'm trying to modify my project file with CTRL+O in visual studio 2005 team edition

    I put <GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>

    in first property group but text become underlined with waveline and message for error was => invalid child element "GenerateResourceNeverLockTypeAssemblies"

    I'm still trying to fix my project.

    Please help me!

    Monday, September 18, 2006 3:25 PM
  • HI again

    I found solution

    Just start framework instalation and select "REPAIR"

    after this my problems disapear

    Tuesday, September 19, 2006 10:18 AM
  • Putting <GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies> in the first group was a god send.  Thanks.  It didn't lower my working set memory usage, but dropped my total app domains from over 50 to 18.  My ide hasn't run this good in weeks.

    For those who don't know to modify the project file, open the vbproj with a text editor.

     

    Wednesday, October 11, 2006 4:47 PM
  • Adding an entry in the project file didn't work for me but this did...

    Control Panel => Add/Remove Programs => Click on Remove Framework button => Repair => Reboot.
    Tuesday, November 28, 2006 6:49 PM
  • You can ignore the "invalid child element" wavy line.
    Thursday, November 30, 2006 2:54 AM
  • This worked, would love to know what is really causingthe issue...

     

    Tuesday, January 23, 2007 4:58 PM
  • I'm adding code to fix these problems, but there's several variations and I can't verify for sure that they're all fixed without good reproes in-house. If anyone posting on this issue can reduce their projects down to the minimum that reproduces the problem (without the GenerateResourceNeverLockTypeAssemblies workaround), please zip it up and send it to MSBUILD@MICROSOFT.COM. I'll use it to verify my fix, and to create an automated test to prevent it ever regressing. This is your and our best assurance that we don't ship this same bug in MSBuild Orcas.
    Thank you in advance,
    Dan (MSBuild team)
    Friday, January 26, 2007 6:46 PM
  • Hi Faisal, thank you for the workaround.

    I have tried to repair the .Net Framework, as suggested in other msgs but at no avail. I have added the element as you suggested in the first group of a .csproj and it worked (at least VS2005 has survived several rebuilds without producing the annoying MBS4018). I'm working with Motorola SMDK 1.3 for .Net, Visual Studio 2005 Standard Ed (8.0.50727.42 RTM.050727-4200) on WinXp with SP 2a.

    Please, could you kindly let me know what has happened in the meantime? (I see that the last post is quite old).

    TIA

    Best regards

    daniel

    Saturday, March 24, 2007 7:53 PM
  • I tried this solution, but it does not work. I will now try to repair the framework installation. I my case it happend after editing a form and adding a new button on the form.
    Wednesday, March 28, 2007 6:46 PM
  •  

    Hi all,

    Thanks for all your inputs.

    By the both ways suggested, i resolved the problem .

     

    Thank you

    aditya

     

    Thursday, March 29, 2007 12:52 PM
  • I think I am able to reproduce the problem. I will send the code, but here is what I did:

     

    I created a new C# windows form application. Then I opened the Resources.resx file and added, say 20 icons at the same time by selecting icon files. This makes the problem appear. If you delete the icons, the error disappears.

     

    I hope this helps at least to find out what's wrong.

     

    regards,

     

    Rudolf Heijink

    Thursday, March 29, 2007 7:12 PM
  • I have properties that have System.Reflection.MemberInfo type and set its value at designtime. Designer stores values in resources as System.Reflection.Runtime[Constructor|Field|Method|Property]Info.

    And I have following error when building project (IuiToolkitTest2) that has at least one such item in resources:

    -------------------------------------------------------------------------------
    The "GenerateResource" task failed unexpectedly.
    System.Reflection.TargetInvocationException: Type  in the data at line 129, position 5, cannot be loaded because it threw the following exception during construction: Could not load file or assembly 'IuiToolkitTest2, Version=2.2.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. ---> System.Xml.XmlException: Type  in the data at line 129, position 5, cannot be loaded because it threw the following exception during construction: Could not load file or assembly 'IuiToolkitTest2, Version=2.2.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. Line 129, position 5. ---> System.IO.FileNotFoundException: Could not load file or assembly 'IuiToolkitTest2, Version=2.2.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
    File name: 'IuiToolkitTest2, Version=2.2.0.0, Culture=neutral, PublicKeyToken=null'
       at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
       at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       at System.Reflection.Assembly.Load(String assemblyString)
       at System.Reflection.MemberInfoSerializationHolder..ctor(SerializationInfo info, StreamingContext context)

    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure logging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

       --- End of inner exception stack trace ---

       --- End of inner exception stack trace ---
       at Microsoft.Build.Shared.ExceptionHandling.RethrowUnlessFileIO(Exception e)
       at Microsoft.Build.Tasks.ProcessResourceFiles.ProcessFile(String inFile, String outFile)
       at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String filename, String classname, Boolean publicClass)
       at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String filename, String classname, Boolean publicClass)
       at Microsoft.Build.Tasks.GenerateResource.Execute()
       at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound) IuiToolkitTest2

    -------------------------------------------------------------------------------

     

    I reinstalled Framework, set GenerateResourceNeverLockTypeAssemblies key - nothing works.

    Tuesday, May 22, 2007 4:03 AM
  • I removed GenerateResourceNeverLockTypeAssemblies and project was built. It's magic)))
    Tuesday, May 22, 2007 3:26 PM
  • I received the following error: error MSB4018: The "Vbc" task failed unexpectedly.

     

    I thought it was something complicated. After removing all of my files from my project and still not being able to compile the project it turned out that the problem was I had manually typed &H98512474 for my base address setting (project properties | Compile tab | Advanced Compile Options button). Although this number conforms with the requirements for a hex number apparently it was too large for compiler to handle. Changing this value to a smaller number resolved the problem.

     

    Here is a recommendation that I received from the helpful folks at Microsoft:

     

    In general, you want to keep base addresses lower than 2gig; although each process that you create runs in a virtual process space that on 32 bits is 4gig, you may be causing a fair amount of memory page swapping with such a large address space.  What you are trying to avoid by setting the base address is loading into a space someone else is loading into.  Collisions occur, and it just slows down the load time of your program.  A small amount, but some.  By default, VS builds programs at 0x10000000.  Now since Microsoft knows that, we move all our dll’s to higher ranges.  For example, most MSFT components load in the 0x60000000 to 0x80000000 range (Use the tool below and open System.dll from the .Net Framework to see an example).

     

    A good tool to use to help you set an appropriate address is dependency walker.  This used to ship as part of Visual Studio but is now open source. http://www.dependencywalker.com/

     

    Build your executable, and open it with dependency walker.  This will show every dll you are dependent on.  Look at the column ‘Preferred Base’ and ‘Virtual Size’.  Set your dll to a base that is not taken, and add your virtual size to ensure that you are not tramping over someone else’s preferred base.

     

    A good rule of thumb is to use the space between 0x10000000 and 0x40000000.  The only time you really need to worry about this is when you’re are building a program with several libraries.  Since your libraries will all want to load into the same space, they will clash and collide.  

    Friday, July 06, 2007 4:46 PM
  • I pasted the code you gave in the .csproj file.  but the same error persists.  Do you know any other work around?
    Friday, July 20, 2007 6:55 AM
  • What about ? :

    Error 223 The "GeneratePolicyManifest" task failed unexpectedly.
    System.UnauthorizedAccessException: Access to the path 'C:\Work\tf_dev\WorkflowComponents\_Main\AE.Indexing.BusinessComponent\bin\x86\Debug\policy.1.0.AE.Indexing.BusinessComponent.config' is denied.
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
       at System.Xml.XmlWriter.Create(String outputFileName, XmlWriterSettings settings)
       at AE.Utility.TeamFoundation.MSBuild.GeneratePolicyManifest.GenerateManifestFile(VersionInfo info, Version curVersion, AssemblyName assemblyShortName, String destPublicKeyToken, String destDir)
       at AE.Utility.TeamFoundation.MSBuild.GeneratePolicyManifest.Execute()
       at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound) AE.Indexing.BusinessComponent

    Using Team Foundation

     

    Monday, August 20, 2007 2:19 PM
  • I haven't seen that. Please open a new bug using the instructions at the top of the forum front page.

    Dan

    Wednesday, August 22, 2007 12:10 AM
  •  Rudolf heijink wrote:

    I think I am able to reproduce the problem. I will send the code, but here is what I did:

     

    I created a new C# windows form application. Then I opened the Resources.resx file and added, say 20 icons at the same time by selecting icon files. This makes the problem appear. If you delete the icons, the error disappears.

     

    I hope this helps at least to find out what's wrong.

     

    regards,

     

    Rudolf Heijink



    This is definitely the problem... Neither one of those workarounds worked for me... I added the <Generate...>true</Generate...> line on the project file and the error kept appearing... I repaired the .net framework twice and didn't work either... Since I knew that the only change I made, before the error appeared, was adding more than 2 images (like 6 or 7) to the resources then I deleted all of them and then started adding one by one (without restarting VS2005) and the error disappeared like magic.

    Hope this works for you
    Tuesday, September 25, 2007 7:27 PM
  • There are several unrelated problems in this thread, many of which you should find are fixed in .NET 3.5 -- certainly the problems that were previously fixed with <GenerateResourceNeverLockTypeAssemblies>. But as far as Christian Sanchez's posting on Sept 25th goes -- I'm not sure I understand this one yet.

     

    Do you see an ImageList type in the .resx when it has this problem? That type is known to me to have a bug. Or are the icons persisted in it with some other type (such as Icon)?

     

    Do you get a callstack you could post?

     

    Thanks, Dan

    Friday, September 28, 2007 9:45 PM
  • After converting from vs2003 to vs2005, I have tried all the threads suggestions, Repair Framework and reboot and the <GenerateResourceNeverLockTypeAssemblies> tag in project file and still get the below error. Where is the line reference coming from? the .resx file?

    Error    10    The "GenerateResource" task failed unexpectedly.
    System.Reflection.TargetInvocationException: Type  in the data at line 135, position 5, cannot be loaded because it threw the following exception during construction: Loading of the ImageList did not succeed. ---> System.Xml.XmlException: Type  in the data at line 135, position 5, cannot be loaded because it threw the following exception during construction: Loading of the ImageList did not succeed. Line 135, position 5. ---> System.InvalidOperationException: Loading of the ImageList did not succeed.
       at System.Windows.Forms.ImageListStreamer..ctor(SerializationInfo info, StreamingContext context)
       --- End of inner exception stack trace ---

       --- End of inner exception stack trace ---
       at Microsoft.Build.Shared.ExceptionHandling.RethrowUnlessFileIO(Exception e)
       at Microsoft.Build.Tasks.ProcessResourceFiles.ProcessFile(String inFile, String outFile)
       at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String filename, String classname, Boolean publicClass)
       at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String filename, String classname, Boolean publicClass)
       at Microsoft.Build.Tasks.GenerateResource.Execute()
       at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound)    MyDLLfile

    Wednesday, October 24, 2007 5:37 PM
  • Hi, this is a known, sporadic bug in the implementation of the serializer or deserializer code in this ImageList type.

     

    However I've never managed to reproduce it internally so that I can bring the problem to the attention of the owners of ImageList. (If you can help me with this, please open a bug using the instructions at the top of the forum.)

     

    Meantime I suggest that you try adding/removing images to the image list, or removing it and re-adding it to your form, that kind of thing, which seems to have helped others in this situation.

     

    Dan

    Wednesday, October 24, 2007 11:42 PM
  • Hi,

    I have a co-worker getting this "GenerateResource" error (see below).  He is useing VS 2005 with SP1.  The project is a Visual Basic one.  I am able to build the same project without problems, he used to be but can not any longer.  We tried adding the

    <GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>

    to the .vbproj file, repairing the .net install (2.0), and reinstalling the VS Service Pack.  Nothing worked.

    Any ideas?

    ------ Build started: Project: TSMain, Configuration: Debug Any CPU ------
    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.Reflection.TargetInvocationException: Type  in the data at line 1030, position 5, cannot be loaded because it threw the following exception during construction: Member 'mcaloktext' was not found. ---> System.Xml.XmlException: Type  in the data at line 1030, position 5, cannot be loaded because it threw the following exception during construction: Member 'mcaloktext' was not found. Line 1030, position 5. ---> System.Runtime.Serialization.SerializationException: Member 'mcaloktext' was not found.
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1616,9): error MSB4018:    at System.Runtime.Serialization.SerializationInfo.GetElement(String name, Type& foundType)
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1616,9): error MSB4018:    at System.Runtime.Serialization.SerializationInfo.GetString(String name)
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1616,9): error MSB4018:    at FarPoint.Win.Spread.CellType.NumberCellType..ctor(SerializationInfo info, StreamingContext context)
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1616,9): error MSB4018:    --- End of inner exception stack trace ---
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1616,9): error MSB4018:
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1616,9): error MSB4018:    --- End of inner exception stack trace ---
    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.ProcessResourceFiles.ProcessFile(String inFile, String outFile)
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1616,9): error MSB4018:    at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String filename, String classname, Boolean publicClass)
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1616,9): error MSB4018:    at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String filename, String classname, Boolean publicClass)
    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 "TSMain.vbproj" -- FAILED.
    Friday, October 26, 2007 12:59 AM
  • Hello,

     

    I have a potential fix for this problem. I just hit that same problem and this is the solution I found.

     

    I had installed an evaluation version of some third party software and created projects using it.

    I then uninstalled the evaluation software and installed the retail software.

    I could suddenly no longer build anything. Error MSB4018.

     

    I knew it had to be Visual Studio 2005 caching something out of sync so I searched my hard drive and found a cache at C:\Documents and Settings\Mikec\Local Settings\Application Data\Microsoft\VisualStudio\8.0\ProjectAssemblies. Subdirectories with temporary names still containing the old assemblies.

    I deleted (moved them temporarily to be safe) these subdirectories and everything started working again.

    This is probably supposed to be a temporary cache that's not getting cleaned out properly.

     

    Hope this works for you.

    Saturday, December 15, 2007 2:21 PM
  • I think there is another potential workaround for some version of this bug (it at least worked for me):

    1. Close all instances of VS
    2. Open a VS Command Prompt
    3. run: devenv /clean
    4. run: devenv /setup
    5. Re-open everything and try to compile again

    I think this performs what Michael Carney suggested, plus some other things although I'll let Microsoft or an MVP clarify more about it as I'm pretty ignorant to it. Smile

     

    My issue was not the images issue as we haven't changed any image stuff in at least a week and the problem just began happening this afternoon.

     

    Good luck and I hope this helps somebody!

    -Shane

    Friday, February 01, 2008 7:59 PM
  • Thank you very much for your fix Jaxidian.  I have had this error occur on three separate occasions and the only fix that was routinely successful was un-installing and re-installing Visual Studio.  Cleaning the devenv caused my application to work immediately, thus saving me several hours. 
    Monday, February 04, 2008 11:07 PM
  •  DevelOnYourShoulder wrote:
    Thank you very much for your fix Jaxidian.  I have had this error occur on three separate occasions and the only fix that was routinely successful was un-installing and re-installing Visual Studio.  Cleaning the devenv caused my application to work immediately, thus saving me several hours. 

     

    Am happy to be of service!! Smile

    Friday, February 08, 2008 2:24 PM
  •  Faisal Mohamood MSFT

    Oh my gosh!!!

    Faisal... You r a Hero, a champion and who knows something even more!!! hehehe

    Thx a lot!!!

    Cheers
    cya
    mr.xalala

    Everybody can save! Just use Ctrl+S! =o]-
    Monday, June 30, 2008 2:30 PM
  • Hi, does anyone have this issue when trying to build a solution file.
    Im running Win7RC and VS2008, think this is a build problem, but im not sure.

    Error 1 The "GenerateResource" task failed unexpectedly.
    System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
       at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
       at System.Drawing.Image.Save(MemoryStream stream)
       at System.Drawing.Image.System.Runtime.Serialization.ISerializable.GetObjectData(SerializationInfo si, StreamingContext context)
       at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
       at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
       at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
       at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
       at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
       at System.Resources.ResourceWriter.WriteValue(ResourceTypeCode typeCode, Object value, BinaryWriter writer, IFormatter objFormatter)
       at System.Resources.ResourceWriter.Generate()
       at System.Resources.ResourceWriter.Dispose(Boolean disposing)
       at System.Resources.ResourceWriter.Close()
       at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(IResourceWriter writer)
       at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(String filename)
       at Microsoft.Build.Tasks.ProcessResourceFiles.ProcessFile(String inFile, String outFile)
       at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass)
       at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass)
       at Microsoft.Build.Tasks.GenerateResource.Execute()
       at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) W_GM

    Friday, June 12, 2009 2:36 AM
  • I had a similar issue and it turned out to be caused by multiple revisions of a particular framework in the "C:\WINDOWS\Microsoft.NET\Framework\" path.  For me, I had v4.0.30128  and v4.0.21006 due to my own chicanery.  I simply renamed the unwanted revision and restarted my build successfully.

    dgp
    Friday, March 05, 2010 5:47 PM
  • I've add this to the first PropertyGroup, but it doesn't solve my problem.

    Here is error text

    Error	6	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)	Components
    
    I'm using VS 2010. Error appears while migrating project to 4.0 framework when I add <NetFx40_LegacySecurityPolicy enabled="true"/> this to devenv.exe.config.


    Wednesday, July 07, 2010 12:11 PM
  • Hi Faisal,

    I have VS2010 with the same problem.  I tried your workaround and it didnt work.   Any other suggestion?

    J

    Thursday, July 29, 2010 8:46 PM
  • I am having the exactly same problem after upgrading my solutions/projects to VS 2010.

    Error 80 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) Juris.SnapIn.Base


    I have added the <NetFx40_LegacySecurityPolicy enabled="true"/> line to the <runtime> group in the devenv.exe.config file. I also tried the <GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies> work around as well as attempting Shane M's suggestion of running devenv /clean and devenv setup.

    I still get the compilation error. I've been butting my head against this for 2 days now. It looks, based on my web searches, that this problem has been around since VS 2005. I would have hoped that MSFT would have provided a solid solution by now.


    Monday, August 23, 2010 5:43 PM
  • Hi

     

    I have the same problem using VS 2010 on W7-64.

    If I add a icon to my small project, I can't build it.

    ------ Build started: Project: Traceproc, Configuration: Release x86 ------

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): error MSB4018: The "GenerateResource" task failed unexpectedly.

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): error MSB4018: System.InvalidOperationException: The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag.

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): error MSB4018: at System.AppDomain.SetupDomainSecurity(AppDomainHandle appDomain, ObjectHandleOnStack appDomainEvidence, IntPtr creatorsSecurityDescriptor, Boolean publishAppDomain)

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): error MSB4018: at System.AppDomain.InitializeDomainSecurity(Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, Boolean generateDefaultEvidence, IntPtr parentSecurityDescriptor, Boolean publishAppDomain)

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): error MSB4018: at System.AppDomain.Setup(Object arg)

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): error MSB4018: at System.AppDomain.nCreateDomain(String friendlyName, AppDomainSetup setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor)

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): error MSB4018: at System.AppDomainManager.CreateDomainHelper(String friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo)

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): error MSB4018: at System.AppDomainManager.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo)

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): error MSB4018: at System.AppDomain.InternalCreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info)

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): error MSB4018: at System.AppDomain.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info)

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): error MSB4018: at Microsoft.Build.Tasks.GenerateResource.Execute()

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)

    ========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

    Regards

    Franz

     

    Friday, March 04, 2011 9:30 AM
  • Hi All,

    We were also having the same problem with VS 2010 on Windows XP SP3, which got solved when we uninstalled and reinstalled the .NET latest Framework dotNetFX40_Full_X86_X64.

    Please do not make any configuration changes which are suggested above!

    Hope this might be of help!

    WIth Warm Regards

    Sujan


    Monday, April 18, 2011 2:32 PM
  • Suggested "fix" for anyone who's recently been upgrading between internal versions...or possibly just a cautionary tale:

    I saw this error manifest (the "GDI+" variant) after we performed a branch on our in-house software, and was mystified even after reading this thread to the bottom, although it put me on the right track.  It turns out that during the upgrade, one of the developers had run a "Find and Replace in files" solution-wide to change the old version number (V130) to the new (V200), and one of the files that got changed was a .resx for one of my windows forms.  

    The actual application version was not in the file; it happened to find the string "V130" inside a line of the text-represented storage for one of my images.  It wasn't enough to break the resx viewer in visual studio, but it was enough to break the serializer during builds, and I only found this after excluding all the forms from my project and re-adding them one by one.

    Obviously, this won't fix everyone's problem here, but if i save at least one other person from having to blow 3 hours manually re-adding forms and rebuilding to find the guilty party, it'll have been worth typing this.

    - Jesse


    Thursday, January 24, 2013 6:34 PM