Thursday, 3 March 2011

Fixing “ResGen.exe exited with code–1073741701” in Visual Studio 2010

Set the 32-bit flag on resgen.exe

Option 1:
  1. Open a Visual Studio command-prompt as an administrator
  2. Navigate to the Microsoft SDKs\Windows\v7.0A\bin directory.
  3. ***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
  4. Set the 32-bit flag to true using corflags.exe
    corflags.exe resgen.exe /32BIT+ /Force
  5. 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-
  6. 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

Option 2:
Add the following line to your csproj file ...

Option 3:
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:

b. Or add this to your project:

1 comment:

  1. This comment has been removed by a blog administrator.