从VS2010安装程序项目安装程序时出现System.BadImageFormatException [英] System.BadImageFormatException When Installing Program From VS2010 Installer Project

查看:222
本文介绍了从VS2010安装程序项目安装程序时出现System.BadImageFormatException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试从VS2010 .NET 4安装程序项目安装Windows服务时出现此错误:

I am getting this error when trying to install a Windows Service from a VS2010 .NET 4 Installer project:

初始化安装时发生异常:System.BadImageFormatException.无法加载文件[file name] .exe或其依赖项之一.此程序集由比当前加载的运行时新的运行时生成,无法加载. "

"Exception occurred while initializing the installation: System.BadImageFormatException. Could not load the file [file name].exe or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded."

我不知道是什么原因造成的.我的解决方案中的所有项目都针对.NET Framework 4进行编译,而安装程序解决方案依赖项则需要.NET 4.有什么明显的我想念的吗?

I can't figure out what is causing this. All the projects in my solution are compiling against .NET Framework 4 and the installer solution dependencies require .NET 4. I have cleaned/rebuilt the solutions and projects to no avail. Is there something obvious I am missing?

推荐答案

您可能具有错误的安装程序先决条件.转到安装项目的属性窗口,在生成下单击先决条件...",并确保已选中.NET Framework 4.您可能仍然需要检查.NET Framework 3.5 SP1.您可能还需要使用Windows Installer 4.1(在同一对话框中).

You likely have the wrong installer prerequisites. Go to your setup project's properties window, click Prerequisites... under build, and ensure that .NET Framework 4 is checked. You likely still have .NET Framework 3.5 SP1 still checked. You probably need to use Windows Installer 4.1 as well (in the same dialog).

还要检查以确保在启动条件下您的.NET Framework版本指向4.

Also check to make sure that in launch conditions your .NET Framework version points to 4.

这篇关于从VS2010安装程序项目安装程序时出现System.BadImageFormatException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆