2013-06-20 29 views
0

錯誤的詳細信息時System.TypeLoadException未處理:硒:webdriver的 - 每次運行最基礎的項目

System.TypeLoadException是未處理
的HResult = -2146233054
消息=無法加載類型「OpenQA。 Selenium.Firefox.FirefoxDriver'from assembly
>'WebDriver,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = null'。
源= webdriver的
類型名= OpenQA.Selenium.Firefox.FirefoxDriver
堆棧跟蹤:
在Driver.Main(字串[] args)
在System.AppDomain._nExecuteAssembly(RuntimeAssembly組件,字串[] args)
在System.AppDomain.ExecuteAssembly(字符串assemblyFile,證據
assemblySecurity,字串[] args)
在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在System.Threading.ThreadHelper.ThreadStart_Context(對象狀態)
在System.Threading.ExecutionContext.RunInternal(ExecutionContext中
>的ExecutionContext,ContextCallback回調,對象的狀態,布爾preserveSyncCtx)
在System.Threading.ExecutionContext.Run(的ExecutionContext的ExecutionContext,
> ContextCallback回調,對象的狀態,布爾preserveSyncCtx)
在System.Threading.ExecutionContext.Run(的ExecutionContext的ExecutionContext,
> ContextCallback回調,對象狀態) 在System.Threading.ThreadHelper.ThreadStart()
的InnerException:

我在Windows 8上運行Visual C#2010。我將目標框架更改爲.Net Framework 4(來自.Net Framework 4 Client Profile)。我試了三大瀏覽器:

//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時,希望自動完成一些簡單的任務。如果我在得到答案之前弄清楚,我會將其作爲更新發布。

編輯:試圖清理格式化一下。

回答

0

發生此錯誤是因爲我在添加引用之前嘗試編譯新的基於Selenium的項目。在我意識到錯誤之後,我添加了對所有程序集的引用,但仍然出現錯誤。事實證明,Visual Studio「卡住」了,因爲我現在意識到這並不少見。 IDE的快速重啓是所有必需的。