分享

CodeEase.com ? Blog Archive ? Windows Form Application: Stopped Working Due to Problem Event Name

 goodwangLib 2013-11-06

There was a windows form application based on .NET 4.0 and Visual Studio 2010, it was working well on a PC which we developed it. when we move its debug folder which including generated executable files, it crashed (We use Windows 7):

CLR20r3Error0

We expanded “Show problem details” button and saw the following information:

Description:
  Stopped working

Problem signature:
  Problem Event Name:    CLR20r3
  Problem Signature 01:    cnserver.exe
  Problem Signature 02:    1.0.0.0
  Problem Signature 03:    4f16e189
  Problem Signature 04:    CnServer
  Problem Signature 05:    1.0.0.0
  Problem Signature 06:    4f16e189
  Problem Signature 07:    225
  Problem Signature 08:    6
  Problem Signature 09:    System.IO.FileNotFoundException
  OS Version:    6.1.7600.2.0.0.256.48
  Locale ID:    1033

Read our privacy statement online:
  http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
  C:\Windows\system32\en-US\erofflps.txt

Due to above information, sees our application missed some files which should be included in output folder. but what the files are ?

Obviously we have some unhandled exceptions in our program due to the error message and the crash, we can not see apparent reason, so we should add the missed exceptions handler.

For example:  AppDomain.CurrentDomain.UnhandledExceptio

Then we add the handlercode into the application startup process, In our case, we add the code in Program.cs file, see the following code, you will see what code you should add into your Program.cs:

    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);


            Application.Run(new Form1());
        }

        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            MessageBox.Show(((Exception)e.ExceptionObject).Message, "Unhandled UI Exception");

        }

        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            MessageBox.Show(e.Exception.Message, "Unhandled Thread Exception");

        }
    }

After we added above code, we ran our application again, and got a popup window like the following:

CLR20r3Error1

So then we know the missed the file is about “Microsoft.VisualBasic.PowerPacks.Vs”, it is a library file. it missed on the new PC, so we just “include” the dll file to output folder in Visual Studio 2010, then our application can work on other PCs.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多