I had this problem in visual studio 2022 after taking an application that was originally using the .net 35 framework and change it to .net 4.8.
After this change, the application compiles without errors, but throws this error at runtime:
System.BadImageFormatException was unhandled Message: An unhandled exception of type 'System.BadImageFormatException' occurred in Unknown Module. Additional information: Could not load file or assembly 'TimersXP.exe' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
SOLUTION:
Change the APP.CONFIG file, leaving the <STARTUP> section with the 4.0 framework only. After that, I did a CLEAR on the project and a BUILD. And the app.config has been changed to:
BEFORE:
<startup>
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v4.0"/>
</startup>
LATER:
I removed the line <supportedRuntime version="v2.0.50727"/>, which apparently forced the 2.0 framework to be used at runtime.
My startup looked like this and the problem was solved:
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
The article that helped me find the solution was this one: (Thanks 🙏)
Comments
Post a Comment