应用程序是否依赖于编译环境? [英] Are applications dependent on the environment where it was compiled?

查看:106
本文介绍了应用程序是否依赖于编译环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的MSI安装程序中有一个System.BadImageFormatException.我已经阅读了有关目标框架的信息,但是我们已经检查过了,它的目标是正确的框架(与我们的质量检查机器相同.NET Framework 4.5.)

We are having a System.BadImageFormatException in our MSI installers. I have already read about the target frameworks, but we already checked and it's targeting the correct framework (.NET Framework 4.5 same with our QA machines).

我们具有完全相同的源代码,但是由构建团队"编译的msi安装程序的结果失败,但是由我们"dev"编译的msi安装程序有效.问题是,构建和编译应用程序的环境是否会影响输出(例如:msi安装程序)?

We have exactly the same source codes, but the results of the msi installer compiled by our 'build team' fails, but the msi installer compiled by us 'dev' works. Question is, does the environment where an application was built and compiled affects the output (example: msi installers)?

推荐答案

一些建议的调试步骤

是触发这些错误的是真正的MSI文件,还是安装后触发了应用程序?

Some Suggested Debugging Steps

So it is the actual MSI file which triggers these errors, or the application after installation?

以下是尝试调试此类问题(无特定顺序)时要考虑的一些想法和问题. 我的赌注在第一个列表中的第3个问题上:

Below are some thoughts and questions to consider when trying to debug issues such as these (in no particular order). My bet is on issue 3 in this first list:

  1. 在运行 MSI本身(或者是setup.exe?)时,还是在尝试启动应用程序后,是否会发生此异常?安装?只是为了验证-我假设是MSI.

  1. Does this exception occur as you run the MSI itself (or is it a setup.exe?), or as you try to launch the application after installation? Just to verify - I assume the MSI.

设置中是否有自定义操作?如果您在MSI中具有托管代码自定义操作,那么您在构建中要针对哪些平台? Any CPU我想吗?请验证.我认为这里的COM-interop存在一些问题,但是我对此细节感到困惑.有时您可能必须选择特定的平台.在这种情况下,您会收到此类错误消息(错误图像). 有关托管代码和部署的完整内容",请参见下面的"托管代码"部分,以及可能导致的一些问题.

Do you have custom actions in the setup? If you have managed code custom actions in your MSI, what platforms do you target in your build? Any CPU I would presume? Please verify. I think there are some issues with COM-interop here, but I am fuzzy on the details. Sometimes you may have to pick a specific platform. In this case you can get such error messages (bad image). See section "Managed Code" below for a whole "rant" about managed code and deployment - and some problems that may result.

无论如何,在您的WiX源文件中,Product elementPlatform attribute的值是什么?可能的值:x86x64intel64intelarmia64.请报告(并尝试使用其他值进行测试-例如x86,x64).这会影响MSI的平台设置.如果不使用WiX,请打开已编译的MSI文件,并检查摘要流中的Platform设置.使用Orca,这是View => Summary Information...-查找Platform.

Regardless of the above, in your WiX source file, what is the value of the Platform attribute in the Product element? Possible values: x86, x64, intel64, intel, arm, ia64. Please report (and try to test with other values as well - x86, x64 for example). This affects the MSI's platform setting. If you don't use WiX - open the compiled MSI file, and check the summary stream for the Platform setting. Using Orca this is View => Summary Information... - look for Platform.

您是否有用于MSI编译和/或安装在生成计算机上的任何恶意软件扫描程序安全软件或其他潜在阻止程序"?还是在您尝试安装的测试系统上? (我们必须经常提到这些问题-即使我们不这样做,人们也会浪费几天的时间-即使它似乎很少是唯一的问题.)

Do you have any malware scanners, security software or other "potential blockers" for MSI compilation and / or installation on your build computer? Or on the test system where you try to install? (We must always mention these issues - people can waste days if we don't - even if it rarely seems to be the only issue).

这是使用亚洲字符的本地化MSI 吗? (或阿拉伯语,或其他复杂字符集?).我刚刚提到了这一点-坦率地说,我看不到它与100%的相关性,但是我想针对您的情况澄清这个变量"(即我们可以消除它作为潜在的错误源).我相信这通常会导致运行时错误,而不是System.BadImageFormatException问题.

Is this a localized MSI using Asian characters? (or Arabic, or any other complex character sets?). This I just mention - frankly I don't see how this is 100% relevant, but I want to clarify this "variable" for your scenario (i.e can we eliminate this as a potential error source). It would generally cause runtime errors, not System.BadImageFormatException issues - I believe.

我认为不同的MSI文件的比较可能不起作用,因为其中一个文件是"错误的图像"?你试过了吗?也许它仍然是有效的COM结构化存储文件-但是msiexec.exe引擎无法处理它?如果是这样,那么工具也许可以很好地读取文件中的内容-我不知道,请尝试一下.

I assume a compare of the different MSI files may not work because one of the files is a "bad image"? Did you try? Maybe it is still a valid COM structured storage file - but the msiexec.exe engine can't handle it? If it is, then tools may be able to read the content inside the file just fine - I don't know, give it a try.

  • 针对您的情况:我最初认为,一个经过编译的MSI在不同位置(环境)的行为会有所不同-因此建议检查是否有任何运输途中的损坏(网络问题,samba问题,存储问题,恶意软件问题等),方法是对不同位置的副本执行 binary diff (二进制比较)(位级别比较).由于您似乎从相同的来源编译了两个(或多个)MSI文件,因此这种二进制比较显然是没有意义的.差异是肯定的.

  • For your scenario: I initially thought a single, compiled MSI behaved differently in different locations (environments) - and hence suggested to check for any damage in transit (network issues, samba issues, storage issues, malware issue, etc...) by doing a binary diff on the copies in the different locations (bit-level comparison). Since you seem to compile two (or more) MSI files from the same sources, such a binary compare is obviously meaningless. Differences are certain.

但是,"内容比较"可能会告诉您一些信息-这会比较MSI内部表/流中的实际内容.我想我将添加有关如何比较可从此处链接到的MSI文件的Q/A(添加:

However, a "content compare" could tell you something - this compares actual content in the tables / streams inside the MSIs. I think I will add a Q/A on how to compare MSI files that I can link to from here (added: How can I compare the content of two (or more) MSI files?). This presumes that the MSI is readable - even if it is not runnable. Only way to know is to try.

我希望并相信上面的列表应该可以帮助您解决问题.

I hope and believe that the above list should help you sort out your problem.

我在下面关于管理代码问题的悬崖上写下自己.这个想法是要描述几个要检查的问题,但这引起了漫长的讨论.我可能会删除下面的所有内容,并可能在其他地方将其复活.它可能与您完全无关.整个主题是托管代码,以及托管代码如何以新的和有趣的"方式崩溃:

I wrote myself off a cliff below on the subject of managed code issues. The idea was to describe a couple of issues to check, but it became a long discussion. I may delete all the stuff below and perhaps resurrect it elsewhere. It may not be relevant for you at all. The overall topic is managed code and how it can crash in new and "interesting" ways:

这是一发不可收拾的答案之一.一世 认为它仍然有价值,把它留在里面.

This is another one of those sprawling answers that got out of hand. I think it still has value, leaving it in.

关于 .NET自定义操作(托管代码)的其他两个问题.我不是这个问题的专家,因为我像瘟疫一样避开了他们(目前-这可能会随着时间而改变).

A couple of further issues with regards to .NET custom actions (managed code). I am far from an expert on this topic, since I shun them like the plague (for now - this may change over time).

出于您的目的,其中有些话题偏离了主题-但我将其保留为MSI使用托管代码的一般注释.

Some of this veered quite a bit off topic - for your purpose - but I will leave it in as general comments on managed code for MSI use.

MSI专家 Chris Painter 就是这个话题的人-他承担了这个潜在的痛苦世界",并且似乎也从此类自定义操作中受益,但是这些由管理的自定义操作似乎通常被认为是有问题的-如果您以幼稚的方式对待它们.务实,权衡好处,以应对下面列出的潜在问题.

MSI expert Chris Painter is the man for this topic - he has taken on this potential "world of pain" and seem to benefit from such custom actions too, but these managed custom actions seem generally accepted to be problematic - if you approach them in a naive way. Be pragmatic and weigh benefits against potential problems listed below.

一条友好的建议:对于全球范围的发行,到目前为止,我永远不会使用托管代码-尽管它变得越来越安全"-我们必须承认这一点.使用此类自定义操作的大规模分发MSI软件包存在太多潜在的错误源(家庭用户可能会卸载.NET,企业用户可能会看到.NET版本被禁用,以及下面的全部问题,我担心赶上22 卸载问题比什么都重要-下文对此有完整说明,等等.)

A friendly piece of advice: for worldwide distribution I would never use managed code as of now - though it is "getting safer" - we have to admit that. There are too many potential error sources for a large scale distribution MSI package using such custom actions (home users may uninstall .NET, corporate users may see versions of .NET disabled, and the whole list of problems below, and I fear "catch 22" uninstall problems more than anything - a whole section on this below, etc...).

正如我所说,我不是专家,但是存在很多严重问题.如果现在分类",克里斯也许可以纠正我. DTF框架(与WiX一起分发)具有支持将托管代码自定义操作dll嵌入常规Win32 DLL包装器中的功能.这有助于提高可靠性. 我将在此处挖掘一些链接以供参考.克里斯一直是这里的先驱和早期采用者.

As I said, I am not an expert, but there are many, and serious problems. Maybe Chris can correct me if they are "sorted" by now. The DTF framework (distributed along with WiX) features support for embedding a managed code custom action dll inside a regular win32 dll wrapper. This helps reliability. I will dig up a few links here for reference. Chris has been a pioneer and early-adopter here.

用于自定义操作的部分托管代码问题:

Partial list of managed code problems for custom action use:

  1. .NET框架可能丢失已禁用已损坏(完全或处于代码所要求/需要的版本中) ).现在,如果您所有的3000个公司软件包都带有嵌入了托管代码的.NET dll,该怎么办?在这种情况下,他们甚至无法卸载-更少的升级.下文第5期有更多内容.

  1. The .NET framework may be missing, disabled or corrupted (entirely or in the version requested / needed for your code). Now, what if all your 3000 corporate packages have a .NET dll with managed code embedded in them? They can't even uninstall in this case - much less upgrade. More below in issue #5.

使用不同的自定义操作定位.NET运行时的不同版本时,所有加载相同的CLR版本. 所以他们告诉了我(在阅读时我无法相信它-请阅读!).我足够去山上奔跑了:-).我听到自己的想法是:"这可能以多种方式爆炸".相应地应用合适的妄想症!万物的邪恶再次抬起了丑陋的头-等等...认真地说,不要听偏执狂,但要警惕严重的问题.这个问题可以解决吗?我猜-我不得不说是,但是忽略不成问题.许多不同的OS和.NET版本都需要认真的UAT/QA.本机dll会做得更好吗?我想是这样.

When targeting different versions of the .NET runtime with different custom actions, all will load the same CLR version. So they tell me (I could not believe it whilst reading it - please read it!). Enough for me to run for the hills :-). "This can blow up in any number of ways" is what I hear myself think. Apply suitable paranoia accordingly! The resident evil of all things rears its ugly head again - etc... Seriously, don't listen to paranoia, but be on alert for serious problems. Is this problem managable? I guess - I would have to say yes, but it is not a problem to ignore. Serious UAT / QA needed on many different OS and .NET versions. Would a native dll do better? I think so.

安装到 GAC 的组件不能用作您在设置中管理的自定义操作(我想是鸡肉还是鸡蛋)的依赖项.这与 Fusion / MSI 的提交模型有关.

Components installed to the GAC can not be used as dependencies for your managed custom actions in the setup (chicken or the egg - I suppose). This has to do with the commit models of Fusion / MSI.

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