.net WatiN System.IO.FileNotFoundException Interop.SHDocVw
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5433990/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WatiN System.IO.FileNotFoundException Interop.SHDocVw
提问by Gilbert Liddell
I have just started to receive the following error when running my WatIn tests.
运行我的 WatIn 测试时,我刚刚开始收到以下错误。
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.
System.IO.FileNotFoundException:无法加载文件或程序集“Interop.SHDocVw,版本=1.1.0.0,Culture=neutral,PublicKeyToken=db7cfd3acb5ad44e”或其依赖项之一。该系统找不到指定的文件。
I have searched the web and tried the following solutions, none of which work.
我在网上搜索并尝试了以下解决方案,但均无效。
- http://linrayusa.blogspot.com/2008/08/vsts-2008-could-not-load-file-or.html
- WatiN Error Could not Load Assembly
- http://blogs.msdn.com/b/dougste/archive/2006/09/05/741329.aspx
- http://linrayusa.blogspot.com/2008/08/vsts-2008-could-not-load-file-or.html
- WatiN 错误无法加载程序集
- http://blogs.msdn.com/b/dougste/archive/2006/09/05/741329.aspx
Can anyone assist?
任何人都可以提供帮助吗?
采纳答案by Grant Crofton
I always end up recompiling watin so it isn't signed, as I couldn't make any of the suggested solutions work either.
我总是最终重新编译 watin 所以它没有签名,因为我也无法使任何建议的解决方案起作用。
You can get the source here: http://watin.org/
您可以在此处获取源代码: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.
打开\source\src 文件夹中的解决方案(有VS2008 和VS2010 版本),打开两个项目并转到属性-> 签名,取消选中“签署程序集”,然后构建解决方案。
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.
您应该在 \source\src\Core\bin 中获得两个 DLL(WatiN.Core.dll 和 Interop.SHDocVw.dll) - 只需将它们复制到您的项目中,它们应该可以正常工作。
回答by scott
Have you tried this:
你有没有试过这个:
Go to solution explorer, click on the interop dll, in properties change "Embed Interop types" to FALSE.
转到解决方案资源管理器,单击互操作 dll,在属性中将“嵌入互操作类型”更改为 FALSE。
Best to use NuGet addon for .net studio and then add reference to wattin via "Add Library Package Reference".
最好将 NuGet 插件用于 .net studio,然后通过“添加库包引用”添加对 wattin 的引用。
回答by Olanrewaju Sideeq
Setting the Interop.SHDocVw, Microsoft.mshtml dlls' Embed Interop Typesproperty to False;
将Interop.SHDocVw, Microsoft.mshtml dll 的Embed Interop Types属性设置为False;
Off course Visual Studio would give you warnings on how to ammend.
当然,Visual Studio 会给你关于如何修改的警告。
回答by Jonathan Stanton
I had this problem and got around it by manually adding the Interop.ShDocVw.dll into the output directory.
我遇到了这个问题,并通过手动将 Interop.ShDocVw.dll 添加到输出目录中来解决它。
回答by Jesus Ramos
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.
您需要 Watin 应该附带的 Interop.ShDocVw.dll 文件,您可能需要将它添加到您的 Visual Studio 解决方案或与 Watin dll 相同的目录(如果它还没有)。如果您确实拥有它,请确保您拥有正确的版本。
回答by Michael A. Volz aka Flynn
If you are using the Visual Studio TestTools you should set the DeploymentAttribute to solve this Problem.
如果您使用的是 Visual Studio TestTools,您应该设置 DeploymentAttribute 来解决这个问题。
Example:
例子:
[DeploymentItem( @"your_path\Interop.SHDocVw.dll" )]
public class WatinTestSuite {
...
}
回答by Reinaldo
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.
就我而言,我尝试了所有建议的解决方案,但没有奏效。我最终以管理员权限关闭并重新打开 Visual Studio 2015,然后该解决方案编译成功。
Hope it helps someone.
希望它可以帮助某人。

