Selenium:WebDriver - System.TypeLoadException在每次运行最基本的项目时都未处理 [英] Selenium: WebDriver - System.TypeLoadException unhandled every time I run the most basic project

查看:402
本文介绍了Selenium:WebDriver - System.TypeLoadException在每次运行最基本的项目时都未处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




System.TypeLoadException未被处理

HResult = -2146233054

Message =无法从程序集加载类型'OpenQA.Selenium.Firefox.FirefoxDriver'>'WebDriver,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = null'。

Source = WebDriver

TypeName = OpenQA.Selenium.Firefox.FirefoxDriver

StackTrace:

at Driver.Main(String [] args)

at System.AppDomain._nExecuteAssembly(RuntimeAssembly程序集,字符串[] args)
$ b $在System.AppDomain.ExecuteAssembly(字符串assemblyFile,证据
assemblySecurity,字符串[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
$ System.Threading.ThreadingHelper.ThreadStart_Context(Object state)
$ System.Threading.ExecutionContext.RunInternal($ ExecutionContext
$ b $ > executionContext,ContextCallback回调,Object状态,布尔值在System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
> ContextCallback回调,对象状态,布尔preserveSyncCtx)

在$ System.Threading.ExecutionContext.Run ExecutionContext executionContext,
> ContextCallback callback,Object state)
在System.Threading.ThreadHelper.ThreadStart()
$ b $ InnerException:




我在Windows 8上运行Visual C#2010。我将目标框架更改为.Net Framework 4(来自.Net Framework 4 Client Profile)。我尝试了三大浏览器:

pre $ // IWebDriver driver = new FirefoxDriver();
// IWebDriver driver = new ChromeDriver();
IWebDriver driver = new OpenQA.Selenium.IE.InternetExplorerDriver();

每次都是相同的错误(基本上是这样)。代码直接出自他们的文档:
http://docs.seleniumhq.org/docs/03_webdriver.jsp#introducing-the-selenium-webdriver-api-by-example



<任何帮助将不胜感激。刚开始与硒,希望自动化几个简单的任务开始。如果我在得到答案之前弄明白了,我会把它作为更新发布。



编辑:试着清理格式化一下。

解决方案

发生此错误是因为我在添加引用之前尝试编译新的基于Selenium的项目。在我意识到错误之后,我添加了对所有程序集的引用,并且仍然有错误。事实证明,Visual Studio卡住了,因为我现在知道并不少见。 IDE的快速重新启动是必要的。


Error details:

System.TypeLoadException was unhandled
HResult=-2146233054
Message=Could not load type 'OpenQA.Selenium.Firefox.FirefoxDriver' from assembly
>'WebDriver, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Source=WebDriver
TypeName=OpenQA.Selenium.Firefox.FirefoxDriver
StackTrace:
at Driver.Main(String[] args)
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext
>executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
>ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
>ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
InnerException:

I am running Visual C# 2010 on Windows 8. I changed the target framework to .Net framework 4 (from .Net framework 4 Client Profile). I tried the big three browsers:

    //IWebDriver driver = new FirefoxDriver();
    //IWebDriver driver = new ChromeDriver();
    IWebDriver driver = new OpenQA.Selenium.IE.InternetExplorerDriver();

Same error every time (basically, anyway). The code comes straight out of their docs: http://docs.seleniumhq.org/docs/03_webdriver.jsp#introducing-the-selenium-webdriver-api-by-example

Any help would be greatly appreciated. Just starting out with Selenium, hoping to automate a few simple tasks to start out. If I figure it out before I get an answer, I'll post it as an update.

Edit: tried to clean up formatting a bit.

解决方案

This error occurred because I tried to compile a new Selenium based project before I added the references. After I realized the mistake I added references to all the assemblies, and still got the error. Turns out Visual Studio was "stuck" as I am now aware is not uncommon. A quick restart of the IDE was all that was necessary.

这篇关于Selenium:WebDriver - System.TypeLoadException在每次运行最基本的项目时都未处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆