I have installed the .net 4 framework on one of my servers.
When I run an installation project created in Visual Studio - get the following error:
Error 1001 Exception occurred while initializing the installation. System.BadImageFormatException: Could not load file or assembly or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
I've definately installed the .net 4 framework on the target machine - what's going on?
Restart your web server and try again. Additionally, you can change the settings on Visual Studio. In my case, I went to Tools > Options > Projects and Solutions > Web Projects and checked Use the 64 bit version of IIS Express for web sites and projects - This was on VS Pro 2015. Nothing else fixed it but this.
Solution. A System. BadImageFormatException error often occurs when a 64-bit assembly is opened by a 32-bit application. In this case, Visual Studio is a 32-bit application and the Design view is attempting to load a 64-bit assembly. Visual Studio assemblies are located in the project references tree.
I eventually found the solution to this, and blogged about it: Deploying .NET 4 Project – Error 1001 (System.BadImageFormatException)
Update: Copied the content from the blog:
"After attending the UK Tech Days events last week in London, I was keen to jump on the Visual Studio 2010 and .net 4.0 bandwagon.
I converted some of our projects here at Crocus to the .net 4 framework (which was incredibly easy – nothing broke!) I even took advantage of some of the quick to implement features in .net 4, and converted some of our massively over-ridden methods to use optional parameters.
One project in particular is a Windows Service, that sends out purchase orders on a schedule. (I recently wrote about how this broke due to Quartz.net expecting a UTC start time)
This has a Visual Studio deployment project associated with it.
After building the newly upgraded .net 4 version of the project, and deploying the .msi file to our target server, I got the following error:
Error 1001 Exception occurred while initializing the installation. System.BadImageFormatException: Could not load file or assembly or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
Now, I had definitely upgraded said server to .net 4 (twice, as a matter of fact – after the first time i received this error!)
After some Googling, some people were saying to change the platform target on my assemblies, which i did, to no avail.
I eventually discovered the problem.
You need to set the .NET Framework Launch Condition
Here’s how to do it:
After rebuilding and deploying my setup file, everything worked fine."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With