none
Resgen.exe fails while compiling 3.5 solution in VS 2010 RTM

    Question

  • I keep getting errors running resgen.exe.    These come & go, but have no idea what is creating them, or why it sometimes has gone away.

    I am using Visual Studio 2010 on Windows 7 64 bit, Intel I7 Quad CPU processor.

    It's not the command line too long problem which was reported with the beta.  

    The project was created using Visual Studio 2008, and the Target Framework is 3.5 (though it is running Tracker from the net 4.0 Tools directory, and uses Common Targets from a 4.0 directory (why is that?).

    Here is my build output:

    ------ Build started: Project: EFExtensions, Configuration: Debug Any CPU ------

    Build started 4/19/2010 10:57:20 AM.

    CoreResGen:

    C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\x64\Tracker.exe @"C:\Users\Daniel\AppData\Local\Temp\cac8de1e09b94b7dae569312df042c96.tmp" /c "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\ResGen.exe" /useSourcePath /r:C:\Windows\assembly\GAC_MSIL\log4net\1.2.10.0__1b44e1d426115821\log4net.dll /r:C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll /r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /r:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.Entity.dll" /r:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\System.Runtime.Serialization.dll" /r:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /compile Messages.resx,obj\Debug\EFExtensions.Messages.resources

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835,9): error MSB6006: "ResGen.exe" exited with code -1073740940.

    Build FAILED.

    Time Elapsed 00:00:05.62

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

    I tried posting the full diagnostic output but apparently it was too long.

    I would appreciate any fixes or work arounds.

    Thanks,

       - Daniel

    Tuesday, April 20, 2010 12:06 AM

Answers

  • Daniel,

    I've been working on this exact issue for the Windows 7.1 SDK.  I want to be really clear here and say that this is not a well-tested solution I am providing.  I haven't tried it on a Visual Studio 2010 installation at all.  But I'm sending it out to get you something as quickly as possible.

    The problem is that resgen.exe sitting in the \Microsoft SDKs\Windows\v7.0A\bin directory is not marked as a 32-bit compliant executable.  You can see what I mean by opening up a Visual Studio command-line prompt, and running corflags resgen.exe in that directory. 

    Compare the results of that to running corflags against the resgen.exe found in the \Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools directory.  You'll see that version is marked as 32-bit.  Your builds targeting .NET 4 that are succeeding are using the latter, while 3.5 builds use the former.  This is causing bitness issues between tracker.exe and resgen.exe, and giving weird failures.

    Here are two potential solutions to try:

    Option 1.      Try using the 64-bit version of tracker.exe, even for 32-bit builds, when targeting .NET 3.5 and lower.  Indicate you want to run ResGen as a tool, and that it is ManagedIL (Managed32Bit doesn't work because of this flagging issue):

    a.     Add this to your MSBUILD command-line:
    /p:ResGenExecuteAsTool=true;ResGenToolArchitecture=ManagedIL;ResGenTrackerSdkPath=”%programfiles(x86)%\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\x64”

    b.     Or add this to your project:
    <PropertyGroup Condition="'$(TargetingClr2Framework)' == 'true'">
      <ResGenExecuteAsTool>true</ResGenExecuteAsTool>
      <ResGenToolArchitecture>ManagedIL</ResGenToolArchitecture>
      <ResGenTrackerSdkPath>$(SDK40ToolsPath)\x64</ResGenTrackerSdkPath>
    </PropertyGroup>

    Option 2.     Set the 32-bit flag on resgen.exe

    a.     Open a Visual Studio command-prompt as an administrator

    b.     Navigate to the Microsoft SDKs\Windows\v7.0A\bin directory.

    c.     ***SAVE A COPY*** of your original resgen.exe file.  This is very important if you want to be able to replace our tweak with the original file without having to repair your installation.
    copy resgen.exe regen.exe.old

    d.     Set the 32-bit flag to true using corflags.exe
    corflags.exe resgen.exe /32BIT+ /Force

    e.     Note the warning about strong name issues.  On my machine the build now succeeds, without needing to do any additional work due to strong name issues.  IF you have problems after trying this method, you can try the following to skip string name verification for that assembly-

    f.      Register resgen.exe for strong name verification skipping using sn.exe
    sn.exe –Vr resgen.exe
    WARNING! This is a security risk.  You are bypassing strongname verification for this assembly, making it possible for malicious code posing as resgen.exe to execute.  To turn verification back on, use
    sn.exe –Vu resgen.exe

    Let me know what you try and whether it is successful or not.

    Thanks!


    Mike Johnson Software Development Engineer in Test Windows C++ Microsoft Corp.

    Monday, April 26, 2010 5:37 PM

All replies

  • FYI -- I discovered a bug report with the same or similar problem: https://connect.microsoft.com/VisualStudio/feedback/details/543804/, however the recommended work arounds didn't work for me, and I submitted my own bug report here:  https://connect.microsoft.com/VisualStudio/feedback/details/552575/build-fails-when-targeted-for-3-5-but-succeeds-with-4-0

    The work around consisted of ensuring you aren't running a 32 bit version of ResGen, started by a 64 bit version of Tracker.  However, when this is ensured by setting the recommended environment variable, the problem still occurs.

       - Daniel

    Tuesday, April 20, 2010 4:49 AM
  • Hi Daniel,

    Thanks for your post.

    Every feedback submitted on our Connect Portal will be evaluated carefully by our engineers. They will let you know their comments further through that portal. Thanks for sharing this feedback link to other community members.

    Regards,

    Nancy Shao [MSFT]
    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! If you have any feedback, please tell us.
    Friday, April 23, 2010 2:55 AM
  • Unfortunately, I have been offered no work around to building my 3.5 projects in VS2010, a key feature of what has been promoted in VS 2010.   It's been 3 days since I originally reported this issue.

    I'm going to have to down grade to VS2008, if I don't get something workable soon.

       - Daniel

    Friday, April 23, 2010 11:07 PM
  • Daniel,

    I've been working on this exact issue for the Windows 7.1 SDK.  I want to be really clear here and say that this is not a well-tested solution I am providing.  I haven't tried it on a Visual Studio 2010 installation at all.  But I'm sending it out to get you something as quickly as possible.

    The problem is that resgen.exe sitting in the \Microsoft SDKs\Windows\v7.0A\bin directory is not marked as a 32-bit compliant executable.  You can see what I mean by opening up a Visual Studio command-line prompt, and running corflags resgen.exe in that directory. 

    Compare the results of that to running corflags against the resgen.exe found in the \Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools directory.  You'll see that version is marked as 32-bit.  Your builds targeting .NET 4 that are succeeding are using the latter, while 3.5 builds use the former.  This is causing bitness issues between tracker.exe and resgen.exe, and giving weird failures.

    Here are two potential solutions to try:

    Option 1.      Try using the 64-bit version of tracker.exe, even for 32-bit builds, when targeting .NET 3.5 and lower.  Indicate you want to run ResGen as a tool, and that it is ManagedIL (Managed32Bit doesn't work because of this flagging issue):

    a.     Add this to your MSBUILD command-line:
    /p:ResGenExecuteAsTool=true;ResGenToolArchitecture=ManagedIL;ResGenTrackerSdkPath=”%programfiles(x86)%\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\x64”

    b.     Or add this to your project:
    <PropertyGroup Condition="'$(TargetingClr2Framework)' == 'true'">
      <ResGenExecuteAsTool>true</ResGenExecuteAsTool>
      <ResGenToolArchitecture>ManagedIL</ResGenToolArchitecture>
      <ResGenTrackerSdkPath>$(SDK40ToolsPath)\x64</ResGenTrackerSdkPath>
    </PropertyGroup>

    Option 2.     Set the 32-bit flag on resgen.exe

    a.     Open a Visual Studio command-prompt as an administrator

    b.     Navigate to the Microsoft SDKs\Windows\v7.0A\bin directory.

    c.     ***SAVE A COPY*** of your original resgen.exe file.  This is very important if you want to be able to replace our tweak with the original file without having to repair your installation.
    copy resgen.exe regen.exe.old

    d.     Set the 32-bit flag to true using corflags.exe
    corflags.exe resgen.exe /32BIT+ /Force

    e.     Note the warning about strong name issues.  On my machine the build now succeeds, without needing to do any additional work due to strong name issues.  IF you have problems after trying this method, you can try the following to skip string name verification for that assembly-

    f.      Register resgen.exe for strong name verification skipping using sn.exe
    sn.exe –Vr resgen.exe
    WARNING! This is a security risk.  You are bypassing strongname verification for this assembly, making it possible for malicious code posing as resgen.exe to execute.  To turn verification back on, use
    sn.exe –Vu resgen.exe

    Let me know what you try and whether it is successful or not.

    Thanks!


    Mike Johnson Software Development Engineer in Test Windows C++ Microsoft Corp.

    Monday, April 26, 2010 5:37 PM
  • Thank you.

    Option 1 didn't work, but that may be that I still have ResGenToolArchitecture=Managed32Bit set in my environment variable (as suggested in a response to a bug report filed for the resgen command line too long issue).

    Option 2, however, required only step d.  I didn't have to do step f.

    It's a good short term solution for me, until the responsible team fixes the problem.

    Thanks!

       - Daniel

    Monday, April 26, 2010 6:55 PM
  • My solution is compling and working great [ had a few things to fix].  I am so grateful for your help!  :-)

    Tuesday, April 27, 2010 1:51 AM
  • dude, AWESOME! thanks man.
    Saturday, May 29, 2010 6:48 PM
  • Hi All,

    I am also getting following set of errors:

    1.  "ResGen.exe" exited with code -2146232576

    2.  "AxImp.exe" exited with code -2146232576

    3.  "TlbImp.exe" exited with code -2146232576

    Machine configuration:

    1.  VS 2010 Professional - 10.0.30319.1 RTMRel

    2.  Windows XP - 2002 SP3

    The projects were build using VS 2005 which I migrated to VS 2010 few months ago. These projects are still targeted to .net 2.0, which is my requirement. After migration it was compiling and working fine however it has started giving these errors all of sudden.

    Note: When I compile these projects on some other machines with same configurations then it works fine. So it looks like machine specific issue.

    I tried the solutions suggested above and also I have re-installed VS 2010 but that also didn't help.

    Can anybody please help here?

    Thanks,

    Deepak Gahlot

     

    Monday, February 14, 2011 1:24 PM
  • When I changed that 32-bit flag, I now receive the following from MSBuild:

    "D:\projects\BenfWaves\trunk\BenfWaves.sln" (default target) (1) ->
    "D:\projects\BenfWaves\trunk\BenfWaves.Client\BenfWaves.Client.csproj" (default
     target) (2) ->
    (CoreResGen target) ->
     C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1835
    ,9): error MSB6003: The specified task executable "ResGen.exe" could not be run
    . The handle is invalid [D:\projects\BenfWaves\trunk\BenfWaves.Client\BenfWaves
    .Client.csproj]
    I'm giving up on multi-target compilation in VS2010. msbuild is hopeless.

    Tuesday, March 22, 2011 6:08 PM
  • I get the same message.  I ported a VS2008 WinForm solution comprised of 3 projects that uses crystal reports.  (the crystal reports issues are fixed)  I am trying to build to ASP 3.5  that did not work, so I tried to build to 4.0 that still gives the

    40 Failed to execute command: "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\ResGen.exe"

    Any ideas on resolution would be great as those mentioned thus far failed.

    Windows 7 64-bit

    Also tried to create a new project under VS2010 that failed as well with the same message running as ASP.NET3.5/recompile with 4.0 that sample project works.  currently, I need the asp 3.5 library. 

    Have even tried the steps mentioned in this blog and make the system run only as 32bit :P  Does VS2010 support ASP.NET 3.5 at all?

    http://blogs.msdn.com/b/visualstudio/archive/2010/06/19/resgen-exe-error-an-attempt-was-made-to-load-a-program-with-an-incorrect-format.aspx

     

     

    ==============================================

    Here is the current VS2010 configuration:

    Microsoft Visual Studio 2010
    Version 10.0.40219.1 SP1Rel
    Microsoft .NET Framework
    Version 4.0.30319 SP1Rel

    Installed Version: Professional

    Microsoft Office Developer Tools   01018-532-2002102-70235
    Microsoft Office Developer Tools

    Microsoft Visual Basic 2010   01018-532-2002102-70235
    Microsoft Visual Basic 2010

    Microsoft Visual C# 2010   01018-532-2002102-70235
    Microsoft Visual C# 2010

    Microsoft Visual C++ 2010   01018-532-2002102-70235
    Microsoft Visual C++ 2010

    Microsoft Visual F# 2010   01018-532-2002102-70235
    Microsoft Visual F# 2010

    Microsoft Visual Studio 2010 Team Explorer   01018-532-2002102-70235
    Microsoft Visual Studio 2010 Team Explorer

    Microsoft Visual Web Developer 2010   01018-532-2002102-70235
    Microsoft Visual Web Developer 2010

    Add Reference Dialog Plus!   1.0
    An significantly enhanced Add Reference dialog for managed code projects.

    AlignAssignments   1.0
    Command for aligning assignments.

    AutoBraceComplete   1.0
    auto brace complete

    Crystal Reports for .NET Framework 4.0  
    Crystal Reports for .NET Framework 4.0


    Document Well 2010 Plus   1.0.10916.0
    This package provides configurable behavior for the Document Well and its tabs. Please be sure to let us know what you like/dislike about this extension.

    ExtensionUpdateCheck   1.0
    Shows a notification icon in the system tray after Visual Studio startup if there are updates available for any installed extensions.

    Microsoft Moles   1.0.0.0
    Moles generator for Visual Studio

    Microsoft Pex   0.94.51023.0
    Microsoft Pex Visual Studio Extensions

    Microsoft Visual Studio 2010 Professional - ENU Service Pack 1 (KB983509)   KB983509
    This service pack is for Microsoft Visual Studio 2010 Professional - ENU.
    If you later install a more recent service pack, this service pack will be uninstalled automatically.
    For more information, visit http://support.microsoft.com/kb/983509.

    Microsoft Visual Studio 2010 SharePoint Developer Tools   10.0.40219
    Microsoft Visual Studio 2010 SharePoint Developer Tools

    Microsoft.VisualStudio.QuickAccess.Package   1.0
    Awesome search bar.

    .NET Reflector
    Visual Studio add-in that integrates .NET Reflector into Visual Studio to allow you to seamlessly debug into third-party code and assemblies, even if you don't have the source code for them.
    Visit www.red-gate.com for more information.
    Copyright (c) 2009-2010 Red Gate Software Inc.

    ANTS Profiler Add-in
    Visual Studio add-in that integrates ANTS Performance Profiler and ANTS Memory Profiler into Visual Studio to allow you to start profiling from inside Visual Studio.
    Visit www.red-gate.com for more information.
    Copyright (c) 2009-2010 Red Gate Software Inc.


    • Edited by tazlulu Friday, March 25, 2011 5:26 PM add more information.
    Friday, March 25, 2011 4:28 PM
  • I saw this post http://www.vc2go.com/2010/05/cruisecontrolnet.html

     

    I was getting the error, I had created a Windows Service project and installer in VS2010 later switched .NET target from 4.0 to 3.5. I noticed there's some additional resource files .resx added in the .NET 4 version which aren't used when you switch to 3.5. Deleting all of the unused .resx files worked for me.

    Tuesday, September 20, 2011 12:00 AM
  • It seems that resgen.exe installed by some version of VS2010 may be corrupted. My solution is to copy the resgen.exe from a machine that does not have this resgen issue to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin. And problem is gone. corflags indidates that 32bit flag is not set in resgen.exe which works.

    • Proposed as answer by Lorenz997 Monday, October 15, 2012 3:29 PM
    Wednesday, November 09, 2011 5:14 PM