VS 2008部署项目创建的安装程序失败,错误为"System.BadImageFormatException". [英] Installer created by VS 2008 deployment project fails with error "System.BadImageFormatException"

查看:333
本文介绍了VS 2008部署项目创建的安装程序失败,错误为"System.BadImageFormatException".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用Visual Studio 2008创建了一个安装程序.VS项目类型是部署项目.该安装程序在某些环境中会失败,但在其他环境中也会完美运行.

I have created an installer with Visual Studio 2008. VS project type is deployment project. This installer fails in some environments but also runs perfectly in some other environments.

例如,安装程序在运行Windows Server 2012 R2 Standard的虚拟机中编译.当然,安装在那里成功.但是,它在运行相同Windows版本的其他虚拟机中失败.

For example, the installer is compiled in virtual machine that runs Windows Server 2012 R2 Standard. Of course installation succeeds there. How ever, it fails in other virtual machine running same Windows edition.

错误消息是:错误1001.初始化安装时发生异常:System.BadImageFormatException:无法加载文件或程序集'file:Custom actions.dll'或其依赖项之一.此程序集由运行时生成比当前加载的运行时新,无法加载."

The error message is: "Error 1001. Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'file: Custom actions.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded."

在安装程序解决方案中的所有应用程序中,目标框架均为3.5.另外,自定义操作"库中的引用还具有.NET 2.0或3.5版.

Target framework is 3.5 in all applications in the installer solution. Also the references in Custom Actions library have .NET version 2.0 or 3.5.

故障环境中缺少什么?从哪里开始搜索?

What is missing in the failing environment? Where to start the search?

推荐答案

此错误实际上只有两个原因:

There are really only two reasons for this error:

  1. 您有32位(或64位)代码试图调用相反体系结构的程序集.在自定义动作调用中,您需要逐一跟踪调用顺序,并注意可能被JIT编译到系统体系结构的AnyCpu程序集类型,而不是要调用的程序集.

  1. You have 32-bit (or 64-bit) code trying to call an assembly of the opposite architecture. In custom action calls you'll need to chase down the calling sequence and be careful of AnyCpu types of assembly that may be JIT compiled to the architecture of the system rather than assemblies you'll call.

不兼容的NET体系结构.在您的情况下,您引用的程序集都是基于NET 2.0 CLR的.如果它们最终在NET 4.0 CLR中运行,它们将失败.查看启动条件以了解发生了什么可能会有所帮助.

Incompatible NET architectures. In your case, the assemblies you referred to are all NET 2.0 CLR-based. If they end up running in a NET 4.0 CLR they will fail. It may help to look at the Launch Conditions to see what's going on.

我还认为Visual Studio 2008不是安装项目的良好基础. VS Community Edition是免费的,并且将托管附加的Installer项目.当然,VS 2008并没有意识到NET 4.0 CLR.

I also think Visual Studio 2008 is not a good basis for a setup project. VS Community Edition is free, and will host the add-on Installer Projects. Certainly VS 2008 is unaware of NET 4.0 CLR.

这篇关于VS 2008部署项目创建的安装程序失败,错误为"System.BadImageFormatException".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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