WatiN Error Could not Load Assembly

20,632

Solution 1

UPDATE: This answer was written before Nuget was released and applies only if you are NOT using Nuget to manage your dependencies. If you are using Nuget see the answer by @Nick Jones

I just had this issue today. You need to download the latest version of WatiN (I'm using 2.0.10.928) and reference the signed Interop.SHDocVw.dll that is provided by WatiN.

Try the follwoing:

  1. Remove all other References to Interop.SHDocVw.dll
  2. Right Click your solution and select 'Clean Solution'
  3. Reference the Interop.SHDocVw.dll that is provided by WatiN
  4. Build your solution.

Hope this helps.

UPDATE: Nick Jones is correct. This should not be an issue if you are using NuGet....but I was also getting this message when using MvcContrib.Mvc3.TestHelper-ci. At first glance it seems like the '-ci' packages is the way to go but I decided to use the MvcContrib.WatiN package for two reasons.

1) I don't get the "Could not load file or assembly" error message

2) The MvcContrib.Mvc3.TestHelper-ci is using an old version of WatiN.Core.dll (1.3.0.4000) where as the MvcContrib.WatiN package is using a newer version (2.0.0.99)

Solution 2

If you've installed and referenced WatiN using NuGet in VS2010, you should already have the correct references, so they don't need to be removed and re-added. But you will still need to change the "Embed Interop Types" setting to False on the Interop.SHDocVw reference.

Solution 3

Check out the Properties of the Reference "Interop.SHDocVw.dll". Change the "Embed Interop Types" to False.

The problem is that it is not copying the dll file in your bin folder. But after this setting, it will do it properly.

I had the same error, and now its working fine.

Share:
20,632
azamsharp
Author by

azamsharp

Mohammad Azam is an iOS Instructor at DigitalCrafts. Before joining DigitalCrafts Azam worked as a senior mobile developer at Blinds.com, A Home Depot company. Azam led the mobile team at Blinds.com to develop the Home Depot blinds/shades online experience. Previously, Azam has worked as a team lead for many large companies including Schlumberger, Baker Hughes, AIG and VALIC. Azam has also published 8-10 personal apps to the App Store, including Vegetable Tree - Gardening Guide which was featured by Apple as the best gardening app in the App Store. Azam is also active on YouTube and maintains his popular channel "AzamSharp" where he shares his iOS knowledge. Azam is also a Udemy instructor where he has published courses on "Swift 2.0" and "iOS MapKit Development Using Swift Language". Azam also frequently contributes iOS articles to the Code Magazine and talks at different iOS conferences all around the country. Before entering the iOS community Azam was an active member of the Microsoft .NET community. Azam was also awarded Microsoft MVP award due to his contributions in the .NET community. Azam is also an instructor on Udemy with more than 2000 students. Azam has earned perfect ratings for his courses on Udemy. You can check out Azam's courses using the link below: http://www.azamsharp.com/courses/ When not developing iOS applications Azam likes to spend time with his family and plan his next trip to the unknown corners of the world.

Updated on July 05, 2022

Comments

  • azamsharp
    azamsharp almost 2 years

    I am getting the following WatiN error:

    Unhandled Exception: System.IO.FileLoadException: Could not load file or assembl y 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=db7cfd3acb5 ad44e' or one of its dependencies. The located assembly's manifest definition do es not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=db

    I copied the shDocvw.dll from System32 to the bin directory but still it is giving me the same problems.

  • Darragh
    Darragh over 13 years
    Additionally, when I added the refernece, I had to change the option for Embed Interop Types to false, and set the Copy Local option to true.
  • Amir
    Amir about 13 years
    In NUnit, we also had to add the [RequiresSTA] attribute to our testfixture.
  • ssmith
    ssmith about 13 years
    Thanks, this fixed it for me. I also had to add [RequiresSTA] as noted in the other answer.
  • JTech
    JTech over 11 years
    +1 This fixed it for me too. (I am using the NuGet package in VS2010).
  • rsbarro
    rsbarro over 11 years
    This worked for me. Make sure you rebuild after changing the setting.
  • Pomster
    Pomster about 8 years
    @MoMo Please not that Darragh comment should be added to your answer. Change Embed Interop Types to false
  • Brian
    Brian over 7 years
    been fighting this for 2 days. this was it.