40

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?

Community
  • 1
  • 1
Gilbert Liddell
  • 1,203
  • 4
  • 14
  • 21
  • 16
    In Visual Studio 2010 this error can occur if the reference to Interop.SHDocVw has it's `Embed Interop Types' set to True. You should disable that option and make sure that the 'Copy Local' option is set to True. More details at http://stackoverflow.com/questions/3635716/visual-studio-copy-dll-refrences-to-output-folder/3636732#3636732 – Greg Bray May 15 '11 at 19:57
  • 2
    Go to solution explorer, click on the interop dll, in properties change "Embed Interop types" to FALSE. – scott Sep 02 '11 at 01:33
  • 1
    This did not work for me, see my question at; http://stackoverflow.com/questions/8728486/getting-started-watin – dannyrosalex Jan 04 '12 at 16:08

7 Answers7

79

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".

scott
  • 1,531
  • 2
  • 16
  • 29
  • 1
    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. – Bronumski Oct 24 '11 at 11:21
  • 1
    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! – dariom Dec 05 '11 at 06:43
  • I did use NuGet and still got this same problem, see my question; http://stackoverflow.com/questions/8728486/getting-started-watin – dannyrosalex Jan 04 '12 at 16:10
8

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.

biegleux
  • 13,179
  • 11
  • 45
  • 52
4

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

Jonathan Stanton
  • 2,531
  • 1
  • 28
  • 35
3

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.

Grant Crofton
  • 8,895
  • 5
  • 28
  • 38
  • 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 – Gilbert Liddell Mar 25 '11 at 15:43
  • 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 Mar 25 '11 at 15:57
  • 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. – Grant Crofton Mar 25 '11 at 16:01
  • 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 Mar 25 '11 at 16:25
  • 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 – Gilbert Liddell Mar 25 '11 at 16:34
  • I don't have a reference to the SHDoc one from my test project, try removing the reference. (Leave it in the folder though). – Grant Crofton Mar 25 '11 at 16:42
  • 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 :-) – Gilbert Liddell Mar 25 '11 at 16:45
  • No probs. It's a sweet tool, just a shame it can be tricky to get working! have fun. – Grant Crofton Mar 25 '11 at 16:50
2

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.

Jesus Ramos
  • 22,940
  • 10
  • 58
  • 88
  • 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. – Gilbert Liddell Mar 25 '11 at 15:18
  • 1
    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. – Jesus Ramos Mar 25 '11 at 15:20
0

In my case, I tried all of the suggested solutions and it did not work. I ended up closing and reopening Visual Studio 2015 with admin privileges, and then the solution compiled successfully.

Hope it helps someone.

Reinaldo
  • 4,556
  • 3
  • 24
  • 24
0

If you are using the Visual Studio TestTools you should set the DeploymentAttribute to solve this Problem.

Example:

[DeploymentItem( @"your_path\Interop.SHDocVw.dll" )]
public class WatinTestSuite {

... 

}