This error is a known problem, likely to be solved in the next
HotFix or Service Pack
and is well documented here . Still, translate and try to summarize what is said in that post. Symptoms
When compiling, an error of type:\u0026lt;\u0026lt;ResGen.exe error: An Attempt Was Made to load a program with an incorrect format>>
concrete example of an error this type:
\u0026lt;\u0026lt;ResourceForm.resx (1436.5): error RG0000: Could not load file or assembly 'file: / / / C: / Users/sjoiner/Desktop/TestForm/ResTest/bin/x86 / Debug / Foo.dll ' or one of STIs dependencies. An Attempt Was Made to load a program with an incorrect format. Line 1436, position 5.>>
concrete example of an error of this kind in Castilian:\u0026lt;\u0026lt;ResourceForm.resx (1436.5): error RG0000: Could not load assembly 'file: / / / C: / Users/sjoiner/Desktop/TestForm/ResTest/bin/x86/Debug/Foo.dll' or one of its dependencies. Attempted to load a program with an incorrect format. Line 1436, position 5.>> Note: The path and name of the assembly (Foo.dll) are just one example. To each among you will hence the name hereinafter called B
Assembly. When you double-click on the error, VisualStudio automatically leads to the form's RESX file.
stage where the error occurs
We are in a 64-bit operating
- Y - Any project that contains resource files. ResX (like Windows Forms). We will call
- Project A Y -
- Project A reference an assembly (call it B Assembly ) Y - Some of the resource files (. ResX) of Project A
- use any type defined in assembly B Y - gives one of the following combinations marked with an X in the following table.
That is, the error appears (summary of the most common):
Whenever
- Project A is being compiled for. Net Framework 3.5 or lower, and B assembly is compiled specifically for 32-bits. O - Whenever
- Project A is being compiled for. Net Framework 4.0, and Project A and Assembly B are compiled for specific platforms, which are also different. Solutions, or rather tinkering
workaround 1 - Avoid
critical scenarios described in the table, changingplatform to build Assembly B , a platform that does not conflict per table above. Or better yet, putting a platform "Any CPU". Obviously, this is not always possible (if the assembly is a third company, for example).
workaround 2 .- Avoid critical scenarios described in the table, changing the compilation platformA. Project For example, through this project. Net Framework 4.0. Obviously this is not always possible. workaround 3 -
Resgen.exe Order to always run in 32 bit by doing the following:1. Cd "% ProgramFiles (x86)% \\ Microsoft SDKs \\ Windows \\ v7.0A \\ Bin"
- 2. Corflags / 32Bit + / Force Resgen.exe
- Unfortunately, This causes a second error type:
To fix this we have 3 options:\u0026lt;ResGenToolArchitecture>1. Add
- property Managed32Bit \u0026lt;/ ResGenToolArchitecture>
- a PropertyGroup in the archives of all projects that generate RESX files. 2. O - If you are invoking MSBuild.exe directly pass the parameters / p: ResGenToolArchitecture = Managed32Bit
- 3. O - Set an environment variable in the window Command in which it is running MSBuild.exe or from which it is opening VStudio environment. 'set RESGENTOOLARCHITECTURE = Managed32Bit'
- workaround 4 -
1. Cd "% windir% \\ Microsoft.NET \\ Framework64 \\ v2.0.50727"
- 2. Setwow Ldr64.exe
- This solution do not like it, because it will affect your entire system and all applications. Net that you run. Conclusions
This problem is a nuisance rather important, and so far no satisfactory solution. In the VisualStudio IDE should be able to specify the bitness where we want to run Resgen.exe for each project. No solution so complex to implement, so hopefully soon be included in a HotFix
.
To learn more about this issue, and read conversations with the experiences of other users, you need to read the original post (in English) available here
.
0 comments:
Post a Comment