开发者

Installing .net 4 project on target server - Error System.BadImageFormatException

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?


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:

  1. Right click on your deployment project in solution explorer. In the context menu, select View -> Launch Conditions
  2. Under 'Version' choose '.NET Framework 4'

After rebuilding and deploying my setup file, everything worked fine."


  1. Click on the installer project, then go to Project>Properties.
  2. Click on the Prerequisites button
  3. Check the “Microsoft .NET Framework 4 (x86 and x64)” box and uncheck the previous version of the framework
  4. Hit ok on the Prerequisites window and on the the properties window.
  5. Right click on the installer project and go to View>Launch Conditions
  6. Highlight the .NET Framework condition and update the following fields in the properties box
    a. InstallURL : http://msdn.microsoft.com/en-us/netframework/aa569263.aspx
    b. Version: .NET Framework 4
  7. Rebuild the installer


Those who still struggle, try the following

Installing .net 4 project on target server - Error System.BadImageFormatException

go to Custom action and update the following to true in the property option

Installing .net 4 project on target server - Error System.BadImageFormatException

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜