开发者

What might cause a .resx file to compile correctly under Windows XP, but fail with error 137 under Windows 7 64 bit?

I have run into a very strange scenario. There is a .resx file in my solution causing problems.

Using Visual Studio 2010 running under Windows XP, the solution compiles without problems.

Using Visual Studio 2010 running under Windows 7, 64 bit, the same solution reports a build failure with error 137

An attempt was made to load a program with an incorrect format. Line 204, position 5. [Path Sanitized]\RemoteFileView.resx

The resource file in question开发者_StackOverflow中文版 appears to be valid, so I am at a loss to explain the problem.

Can anyone suggest what might have gone wrong?

Clarification: The line in question that VS 2010 is complaining about is a simple </data> element. The XML appears to be well formed.


Based on the string in the error message, there is a BadImageFormatException being thrown when the designer is trying to load.

It seems highly likely that it's a bitness mismatch issue. Have you tried rebuilding the solution? Can you build on the command line via MSBuild? Are all of your projects targetting "Any CPU", or do you have a processor specific project?

Please take a look at this blog post where Sara Joiner describes the circumstances where you may see this issue in detail.


I also had the same issue when migrating my system to 64-bit. The only solution for me was that every time I changed something in the gui and the resx-files updated, I had to do the following:

Replace all occurences of the string j00L to j0yL.

You will now be able to compile!


It's a bug with Visual Studio that microsoft has known about for over a year. See below links for more information:

  • 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#comments
  • https://connect.microsoft.com/VisualStudio/feedback/details/532584/error-when-compiling-resx-file-seems-related-to-beta2-bug-5252020?wa=wsignin1.0
  • https://connect.microsoft.com/VisualStudio/feedback/details/554759/error-in-control-resx-file-when-adding-imagelist
  • https://connect.microsoft.com/VisualStudio/feedback/details/586646/the-generateresource-task-failed-unexpectedly

I recently had to upgrade our windows forms project to .NET 4.0 because as soon as we touched (read saved) a designer it correupted our embedded images. The line of the error was just a load of bollocks.

Unfortunately none of the suggested workarounds worked for us so we had to bite the bullet and upgrade.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜