C#附加信息:外部组件抛出异常

时间:2016-06-13 20:50:28

标签: c# error-handling

我收到此错误

Additional information: External component has thrown an exception.

只有在调试模式下,当我打开我的程序时,它才能正常工作,但在调试模式下,它会抛出这个错误而我不确定为什么。

以下是它抛出错误的代码。

                Thread tokenThread = new Thread(new ThreadStart(new Action(() =>
            {                    
                using (System.Windows.Forms.WebBrowser wb = new System.Windows.Forms.WebBrowser())
                {
                    wb.DocumentCompleted += wb_DocumentCompleted;
                    wb.Tag = args.Account;
                    wb.ScriptErrorsSuppressed = true;
                    wb.Url = new Uri(String.Format("file:///{0}/md.html", Directory.GetCurrentDirectory()));

                    System.Windows.Forms.Application.Run();
                }                  
            })));

这就是它在调试器中抛出它。

System.Windows.Forms.Application.Run();

有人可以指出我的错误吗?

1 个答案:

答案 0 :(得分:0)

猜测可能是这一行:Directory.GetCurrentDirectory(),尝试将其替换为Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)。从IDE运行时,当前目录可能与直接从资源管理器运行。

相关问题