I have a recurrent issue with .NET applications that don't start (on others systems than mine). The fact is that I cannot, unfortunately, always create a smoothly running package. Therefore I often have to send a ZIP file of my Debug or Release folder.
我有一个经常出现的.NET应用程序无法启动的问题(在其他系统上而不是我的)。事实是,不幸的是,我不能总是创造一个顺畅运行的包。因此,我经常要发送Debug或Release文件夹的ZIP文件。
My real problem is that these applications doesn't tell WHY they're not starting. I just get no exception at all if I start them from the command line, neither in the EventLog, or even if I try to print on the output the result of a Try Catch block on all my application... am I missing something?
我真正的问题是这些应用程序没有告诉他们为什么没有启动。如果我从命令行启动它们,在EventLog中,或者即使我尝试在输出上打印我的所有应用程序上的Try Catch块的结果,我也完全没有例外...我错过了什么?
Most of the time, it's missing libraries, or security related issues. But it would be nice to find what exactly is going on painlessly :D
大多数情况下,它缺少库或安全相关问题。但是,毫不费力地找到确切的结果会很好:D
4 个解决方案
#1
Have you tried looking at the fusion logs? Suzanne Cook has an article on this here.
你试过看融合日志吗? Suzanne Cook在这里有一篇文章。
Another thing to do (to minimise silent errors): minimise your Main
method; the reason for this is that JIT works per-method, and if it can't JIT Main
it can't use your exception handling:
另一件事(最小化无声错误):最小化您的Main方法;原因是JIT是按方法工作的,如果它不能JIT Main,它就不能使用你的异常处理:
/* for winform, you still new [STAThread] here */
static void Main() {
try {
MainCore();
} catch (Exception ex) {
// shout about it
}
}
[MethodImpl(MethodImplOptions.NoInlining)] // usually overkill
static void MainCore() {
// real code
}
#3
I've had a problem whereby WPF applications wouldn't start - it turns out that the problem was related to fonts on the user's PC - disabling the WindowsPresentationFontCache service fixed the problem.
我有一个问题,WPF应用程序无法启动 - 事实证明问题与用户PC上的字体有关 - 禁用WindowsPresentationFontCache服务解决了问题。
I also found a post elsewhere with the following info...
我还在其他地方发现了一个帖子,其中包含以下信
...for some unknown reason, the customer had wrong entries in the registry keys that are used to build that “default font family” cache cited in the stack trace. The customer was asked to export the entries under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts, and send the file to me. There were several font filenames strangely starting with dashes (---). These were fixed, and a registry file was sent back to the customer to import. After that, the application successfully started!
...由于某种未知原因,客户在注册表项中有错误的条目,用于构建堆栈跟踪中引用的“默认字体系列”缓存。客户被要求导出HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Fonts下的条目,并将文件发送给我。有几个字体文件名奇怪地以破折号(---)开头。这些已修复,并将一个注册表文件发送回客户进行导入。之后,应用程序成功启动!
There may also be the need of deleting your font cache, as per instructions in this link http://support.microsoft.com/kb/937135
根据此链接中的说明,可能还需要删除您的字体缓存http://support.microsoft.com/kb/937135
#4
I know it's not addressing the problem directly - but have you tried publishing your application (assuming you're using Visual Studio of course)? This should wrap up everything you need into the installer.
我知道它不是直接解决问题 - 但你是否尝试发布你的应用程序(假设你当然使用Visual Studio)?这应该将您需要的所有内容包装到安装程序中。
#1
Have you tried looking at the fusion logs? Suzanne Cook has an article on this here.
你试过看融合日志吗? Suzanne Cook在这里有一篇文章。
Another thing to do (to minimise silent errors): minimise your Main
method; the reason for this is that JIT works per-method, and if it can't JIT Main
it can't use your exception handling:
另一件事(最小化无声错误):最小化您的Main方法;原因是JIT是按方法工作的,如果它不能JIT Main,它就不能使用你的异常处理:
/* for winform, you still new [STAThread] here */
static void Main() {
try {
MainCore();
} catch (Exception ex) {
// shout about it
}
}
[MethodImpl(MethodImplOptions.NoInlining)] // usually overkill
static void MainCore() {
// real code
}
#2
Take a look at the Assembly Binding Log Viewer.
看看Assembly Binding Log Viewer。
#3
I've had a problem whereby WPF applications wouldn't start - it turns out that the problem was related to fonts on the user's PC - disabling the WindowsPresentationFontCache service fixed the problem.
我有一个问题,WPF应用程序无法启动 - 事实证明问题与用户PC上的字体有关 - 禁用WindowsPresentationFontCache服务解决了问题。
I also found a post elsewhere with the following info...
我还在其他地方发现了一个帖子,其中包含以下信
...for some unknown reason, the customer had wrong entries in the registry keys that are used to build that “default font family” cache cited in the stack trace. The customer was asked to export the entries under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts, and send the file to me. There were several font filenames strangely starting with dashes (---). These were fixed, and a registry file was sent back to the customer to import. After that, the application successfully started!
...由于某种未知原因,客户在注册表项中有错误的条目,用于构建堆栈跟踪中引用的“默认字体系列”缓存。客户被要求导出HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Fonts下的条目,并将文件发送给我。有几个字体文件名奇怪地以破折号(---)开头。这些已修复,并将一个注册表文件发送回客户进行导入。之后,应用程序成功启动!
There may also be the need of deleting your font cache, as per instructions in this link http://support.microsoft.com/kb/937135
根据此链接中的说明,可能还需要删除您的字体缓存http://support.microsoft.com/kb/937135
#4
I know it's not addressing the problem directly - but have you tried publishing your application (assuming you're using Visual Studio of course)? This should wrap up everything you need into the installer.
我知道它不是直接解决问题 - 但你是否尝试发布你的应用程序(假设你当然使用Visual Studio)?这应该将您需要的所有内容包装到安装程序中。