我有一个open source C# app与 WiX安装程序,依赖于.NET 4.5。
- Windows7 64 位(安装了 .NET 4.5)用户表示它运行良好。
- Windows7 32 位(安装了 .NET 4.5)用户表示它崩溃了。
所以我安装了 Windows7 32 位(在 VirtualBox 中),安装了应用程序,但确实崩溃了:
问题签名 09 是 System.IO.DirectoryNotFound
,Windows 事件查看器提到 C:\Windows\system32\KERNELBASE.dll
,如果这可以提供线索.
然后我决定在同一台计算机上安装 Visual C# 2010 Express,并且...
惊喜:应用程序不再崩溃(无论是安装的应用程序还是通过 Visual C# 执行时)
如何避免这种崩溃?
我无法要求所有用户安装 Visual C#...
最佳答案
我认为这更多的是一种预感,而不是答案,但它似乎有所帮助。我将完成我的思考过程。
基于该应用程序在 64 位而不是 32 位上运行的事实,我立即想到 BadImageFormatException
或在 Program Files (x86)
中查找的编码路径不正确> (或类似 64 位/32 位注册表值的内容)。但后来我们发现安装了 VS 后一切都很好,这很奇怪。因此,我开始查看项目文件和引用资料。几乎所有内容都是托管代码/MSIL,因此看起来与 32 位/64 位问题无关。然而,在其中一个引用项目 (SparkleLib.Cmis
) 中,我看到了对 System.Data.SQLite
的引用,我知道它具有非托管组件。我用谷歌搜索了docs 。他们提到了这一点:
All the "static" packages contain either native or mixed-mode assembly binaries linked statically to the appropriate version of the Visual C++ runtime. Typically, these packages are used in cases where customer machines may not have the necessary version of the Visual C++ runtime installed and it cannot be installed due to limited privileges.
所以我现在非常确定,这是一个部署不正确的System.Data.SQLite
,它恰好在开发箱上工作,因为 VS 已经在那里了。 OP 已确认这确实是问题所在。
关于仅当未安装 Visual C# 且仅在 32 位上时,C# 应用程序才会崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13449186/