简体   繁体   English

我的C#程序在其他计算机上导致APPCRASH

[英]My C# program cause APPCRASH in other's computers

I wrote a program with .Net 4.0 in C#, and it works well in the two computers in which I compiled it. 我用C#用.Net 4.0编写了一个程序,并且在我编译该程序的两台计算机中都可以很好地工作。 But when I copy the program into other's computers, the program even didn't show it's UI, and gives out a MessageBox like this: 但是,当我将该程序复制到其他计算机上时,该程序甚至没有显示其UI,而是发出了一个MessageBox,如下所示: 在此处输入图片说明

The box says my program has cause an APPCRASH. 盒子上说我的程序引起了APPCRASH。 Anyone has any idea how to fix the problem? 任何人都知道如何解决该问题?

Could be several reasons. 可能有几个原因。 One of the more common ones is that you're compiling it for a .NET framework that the target machine does not have. 较常见的一种是针对目标计算机没有的.NET框架进行编译。 Another could be that you're compiling for 64-bit, while target machines are 32-bit. 另一个可能是您要为64位编译,而目标计算机是32位。

Some of the steps to fix this: 解决此问题的一些步骤:

If you're using Visual Studio, right click on your project and go to Properties . 如果您使用的是Visual Studio,请右键单击您的项目,然后转到“ Properties In Application tab check to see which Target framework is being listed. 在“ Application选项卡中,检查以查看列出了哪个Target framework It could be .NET Framework 4.5.1. 可能是.NET Framework 4.5.1。
Change it to .NET Framework 4 Client Profile and see if it runs on your target machines. 将其更改为.NET Framework 4客户端配置文件,然后查看它是否在目标计算机上运行。 Also, under Build check to see which Platform target options you have selected and adjust accordingly. 另外,在“ Build下检查以查看已选择的Platform target选项并进行相应调整。 It might be helpful to select x86 rather than Any CPU. 选择x86而不是Any CPU可能会有所帮助。

Other thoughts/tips: 其他想法/提示:

From the screenshot, it appears that you're running it on Windows 7 machines, so I doubt that .NET framework is the issue; 从屏幕截图中可以看出,您似乎正在Windows 7计算机上运行它,因此我怀疑.NET Framework是问题所在。 in that case, ensure that target machines contain all the appropriate libraries that you're using. 在这种情况下,请确保目标计算机包含您正在使用的所有适当的库。 If you have some non-native libraries, make sure that you set Copy Local to true for them. 如果您有一些非本机库,请确保Copy Local它们的“ Copy Local设置为true

By the way... when you say you copy it, I'm assuming you're copying all the appropriate files along with the executable, right? 顺便说一句...当您说要复制它时,我假设您正在复制所有适当的文件以及可执行文件,对吗? There might be some files, such as libraries, app configuration files, etc., that you need to copy along with it. 您可能需要复制一些文件,例如库,应用程序配置文件等。

David Khaykin mentioned the fact that you might have an unhandled exception there. 大卫·海金(David Khaykin)提到了一个事实,即您那里可能有未处理的异常。 Therefore, as suggested in this SO thread , you may want to implement an event handler for the AppDomain.CurrentDomain.UnhandldedException event and check the value of the e.ExceptionObject.ToString() . 因此,如该SO线程中所建议,您可能想要为AppDomain.CurrentDomain.UnhandldedException事件实现一个事件处理程序,并检查e.ExceptionObject.ToString()的值。

Here's MSDN link to help you with that (scroll to the bottom to see an example): http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception(v=vs.110).aspx 这是MSDN链接可帮助您解决此问题(滚动至底部以查看示例): http : //msdn.microsoft.com/zh-cn/library/system.appdomain.unhandledexception(v=vs.110 ) .aspx

Some ways to analyze crashes: 分析崩溃的一些方法:

Here's a neat article that describes how to analyze your crashes: 这是一篇简洁的文章,描述了如何分析崩溃:

http://blogs.msdn.com/b/anandbms/archive/2005/04/20/410225.aspx http://blogs.msdn.com/b/anandbms/archive/2005/04/20/410225.aspx

It uses AdPlus, which you can read more about and obtain at http://support.microsoft.com/kb/286350 它使用AdPlus,您可以在http://support.microsoft.com/kb/286350上阅读并了解更多信息。

Here's a more direct link to WinDbg debugging tool: http://msdn.microsoft.com/en-us/windows/hardware/hh852365 (scroll down halfway and make sure you get the Windows 7 version if that's your OS). 这是WinDbg调试工具的更直接链接: http : //msdn.microsoft.com/zh-cn/windows/hardware/hh852365 (向下滚动并确保获得Windows 7版本,如果这是您的OS)。

Those are just some of the things that I've done over the course of my C# adventuring, so hopefully one of them can help you. 这些只是我在C#冒险过程中所做的一些事情,因此希望其中之一可以为您提供帮助。

我曾经遇到此问题( APPCRASH引用kernelbase.dll ),在我的情况下,由于用户配置文件损坏(没有确定的原因,但我之前遇到过几次蓝屏),我遇到了一个问题,这阻止了一些(但不是全部) !)我的应用程序突然无法使用:要进行验证,请在故障计算机上尝试创建新的Windows用户,将应用程序复制过来并尝试执行。

I checked the event log in my target machine, and foud some useful information. 我在目标计算机上检查了事件日志,发现了一些有用的信息。 The information is just next to the "APPCRASH" one, and it says like "can't find a file...". 该信息仅在“ APPCRASH”旁边,并显示“找不到文件...”。 Then I checked my program and found a lib haven't been copied there by the compiler. 然后我检查了程序,发现编译器未将库复制到该库中。

It seems the event log can really help. 看来事件日志确实可以提供帮助。

Thank you all who cared! 谢谢所有关心的人!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM