WatiN System.IO.FileNotFoundException Interop.SHDocVw

25,341

Solution 1

I always end up recompiling watin so it isn't signed, as I couldn't make any of the suggested solutions work either.

You can get the source here: http://watin.org/

Open the solution in the \source\src folder (there are VS2008 and VS2010 versions), open both projects and go properties -> Signing, uncheck 'sign the assembly', and build the solution.

You should get two DLLs in \source\src\Core\bin (WatiN.Core.dll and Interop.SHDocVw.dll) - just copy these into your project and they should work Ok.

Solution 2

Have you tried this:

Go to solution explorer, click on the interop dll, in properties change "Embed Interop types" to FALSE.

Best to use NuGet addon for .net studio and then add reference to wattin via "Add Library Package Reference".

Solution 3

Setting the Interop.SHDocVw, Microsoft.mshtml dlls' Embed Interop Types property to False;

Off course Visual Studio would give you warnings on how to ammend.

Solution 4

I had this problem and got around it by manually adding the Interop.ShDocVw.dll into the output directory.

Solution 5

You need the Interop.ShDocVw.dll file that should have come with Watin, you might have to add it to your visual studio solution or to the same directory as the Watin dll's if it's not already there. In the case that you do have it make sure that you have the correct version.

Share:
25,341
Gilbert Liddell
Author by

Gilbert Liddell

Updated on July 26, 2022

Comments

  • Gilbert Liddell
    Gilbert Liddell almost 2 years

    I have just started to receive the following error when running my WatIn tests.

    System.IO.FileNotFoundException : Could not load file or assembly 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=db7cfd3acb5ad44e' or one of its dependencies. The system cannot find the file specified.

    I have searched the web and tried the following solutions, none of which work.

    Can anyone assist?

  • Gilbert Liddell
    Gilbert Liddell over 13 years
    Hi, thanks for the reply. I have added the Interop.ShDocVw.dll that was downloaded with Watin. I did this by right clicking on the references in VS and adding the downloaded file.
  • Jesus Ramos
    Jesus Ramos over 13 years
    Also when building you might have to change an option for the solution that copies the reference DLL's to your bin/debug or bin/release folders, this is what happened to me before but not with Watin.
  • Gilbert Liddell
    Gilbert Liddell over 13 years
    Hi, I dowloaded the code, opened the VS210 sln, opened each projects properties (core and unit tests) and got the following error when trying to build, any suggestions?? Error 1 Friend access was granted to 'WatiN.Core.UnitTests, PublicKey=BLA', but the output assembly is named 'WatiN.Core.UnitTests, Version=2.0.50.1179, Culture=neutral, PublicKeyToken=null'. Try adding a reference to 'WatiN.Core.UnitTests, PublicKey=BLA changing the output assembly name to match. c:\Users\gilbertl\Downloads\WatiN-2.0.50.1179 (1)\WatiN-2.0.50.1179-net-2.0\source\src\Core\bin\WatiN.Core‌​.dll
  • Grant Crofton
    Grant Crofton over 13 years
    Oh yeah, sorry, forgot about that. Select 'Show All Files' for the Core project, then open Properties -> AssemblyInfo.cs. Change the line that says [assembly: InternalsVisibleTo("WatiN.Core.UnitTests, [whatever]... to [assembly: InternalsVisibleTo("WatiN.Core.UnitTests")], and try again.
  • Grant Crofton
    Grant Crofton over 13 years
    BTW, if you can get Jesus's solution working, I'd do that - this is a bit of a pain to do, and I'm sure isn't necessary.
  • Gilbert Liddell
    Gilbert Liddell over 13 years
    Thanks again but still no joy. I've build the project and copied the new files to my project. Deleted the old references, cleaned the project and referenced the new files. I build and run tests and still get the original error. System.IO.FileNotFoundException : Could not load file or assembly 'Interop.SHDocVw ............
  • Gilbert Liddell
    Gilbert Liddell over 13 years
    It looks like the watin.core.dll was updated when I built the source but not Interop.SHDocVw.dll it still has the date i downloaded Watin. Full error System.IO.FileNotFoundException : Could not load file or assembly 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=db7cfd3acb5ad44e' or one of its dependencies. The system cannot find the file specified
  • Grant Crofton
    Grant Crofton over 13 years
    I don't have a reference to the SHDoc one from my test project, try removing the reference. (Leave it in the folder though).
  • Gilbert Liddell
    Gilbert Liddell over 13 years
    Bingo, thanks very much for your help. A few hoops to jump through there but main thing is my tests are back up and running. Thanks again :-)
  • Grant Crofton
    Grant Crofton over 13 years
    No probs. It's a sweet tool, just a shame it can be tricky to get working! have fun.
  • Bronumski
    Bronumski over 12 years
    I had previously downloaded WatiN manually and had everything working. I have just done a pull from NuGet and everything stopped working. Using your suggestion I looked at how the interop dll was being used and it had defaulted to Embed Interop types to False. NuGet install is obviously broken for WatiN but your advice sorted it all out.
  • dariom
    dariom over 12 years
    I've just started using WatIn. I installed it with NuGet and encountered this issue. Your fix worked perfectly. I guess this is only an issue for .Net 4-based test projects. The option to embed interop types in the main assembly is a .Net 4 feature I believe. Thanks for the help!
  • dannyrosalex
    dannyrosalex over 12 years
    I did use NuGet and still got this same problem, see my question; stackoverflow.com/questions/8728486/getting-started-watin
  • Kieren Johnstone
    Kieren Johnstone almost 12 years
    Hi Olanrewaju (welcome to StackOverflow!), this answer is not very clear. Could you explain a little more?
  • Amr Elgarhy
    Amr Elgarhy over 10 years
    This is what I did to solve my issue, see there as well bhameyie.com/2011/10/09/watin-annoying-interop-issue