未处理的异常:system.typeInitializationException [英] unhandled exception: system.typeInitializationException
本文介绍了未处理的异常:system.typeInitializationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用硒的webdriver导航网站和发送键。
它在开发环境/电脑工作的罚款。但我得到的错误,当我尝试通过不同的计算机上运行。
命名空间McaidWebToolImport
{
类节目
{
静态无效的主要(字串[] args)
{
Console.WriteLine(请输入批号:);
字符串batchnumber =到Console.ReadLine(); 如果(batchnumber!=)
{
IWebDriver驱动1 =新InternetExplorerDriver(@C:\\ IEDriverServer \\);
。driver1.Navigate()GoToUrl(http://website.com/webtool/physPop.asp?b=+ batchnumber); System.Threading.Thread.Sleep(2000);
driver1.Quit();
}
其他
{
Console.WriteLine(重新运行与有效批号申请);
Console.WriteLine(\\ n \\ n preSS Esacpe键(ESC)退出);
而(Console.ReadKey(真)。重点= ConsoleKey.Escape!);
}
}
}
}
解决方案
您可以尝试处理异常(try / catch语句),那么你可以检查的InnerException,并得到了什么的失败的详细信息。
可能的大会,是在开发机器上present但不是在目标机器上。
I am using selenium webdriver to navigate to website and send keys. It is working fine in development environment/computer. But I am getting error, when im trying to run through different computer.
namespace McaidWebToolImport
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the batch number: ");
string batchnumber = Console.ReadLine();
if (batchnumber != "")
{
IWebDriver driver1 = new InternetExplorerDriver(@"C:\IEDriverServer\");
driver1.Navigate().GoToUrl("http://website.com/webtool/physPop.asp?b=" + batchnumber);
System.Threading.Thread.Sleep(2000);
driver1.Quit();
}
else
{
Console.WriteLine("Re-run the application with valid batch number");
Console.WriteLine("\n\nPress Esacpe key (Esc) to exit");
while (Console.ReadKey(true).Key != ConsoleKey.Escape);
}
}
}
}
解决方案
You might try handling the exception (try/catch), then you can inspect the InnerException and get more detail about what's failing.
Possibly an Assembly that's present on your development machine but not on the target machine.
这篇关于未处理的异常:system.typeInitializationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文