Watin Exception [duplicate] - c#

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.

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.

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:
Remove all other References to Interop.SHDocVw.dll
Right Click your solution and select 'Clean Solution'
Reference the Interop.SHDocVw.dll that is provided by WatiN
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)

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.

Related

How to resolve "The located assembly's manifest definition does not match the assembly reference." error?

I downloaded source code for pdfiumviewer from git hub. I made changes to one of the projects in that solution.Then I added that project to my application and added reference of that project to one my application's project.I had to uncheck the Signing option for the PDfiumViewer project, as some of the dll in that project are unsigned.I am able to build the application successfully.But at run time when I create an object of one of the class of PDfiumviewer project.It gives me the following error:
Could not load file or assembly 'PdfiumViewer, Version=2.11.0.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)
The version number of the assembly is correct.So, why am I getting this error?
The problem was that I had added reference of old unmodifed PdfiumViewer dll to another project.Hence, there was conflict between the two dlls (old and customized) at runtime.I removed the old dll reference and it worked.
Ive also encountered this issue, my scenario was thou that I had to add a reference from another solution into my project removing the reference was not an option - what worked for me was reinstall SQLclient from nuget package managerer on both solution. Hopes it helo someone else
The issue here is that you have a library that references v2.11.0.0 of the Pdfium library. This library could be an assembly that you built earlier, or another assembly that came from Pdfium that references this version of the library. When you built your version of the library you probably didn't use this same version number, and it wouldn't have been strong named correctly. To fix this, you can add an assembly binding redirect in your applications configuration file to redirect the offending library to your custom built one.
I wrote a program to fix this issue automatically: https://github.com/BackTrak/DependencyFixup/releases/tag/1.0.0.0
I know this question is old, but hopefully this helps out others!

FileLoadException - Could not load file or assembly

All of a suddon, I'm getting a FileLoadException when getting an instance of a class from Ninject.
The exact exception is the following:
System.IO.FileLoadException: "Could not load file or assembly 'Quartz, Version=2.3.3.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"
When reading the error message, it seems quite clear that it tries to load an assembly of Quartz with version 2.3.3.0 but the specified version is another... but I don't get why it even loads version 2.3.3.0.
I searched the whole solution (inclusive the .csproj) for Quartz references and every reference states v1.0.1.2.
I've searched the path on the file system for Quartz.dlls but could only find dlls of version 1.0.1.2 so I don't understand why it tries to load 2.3.3.0.
Do you know of any steps I could try to solve this exception?
Thanks in advance
Check the class library that includes Quartz. Make sure that the platform version is consistent. You can do this by right clicking on the project file and selecting properties. Then check the assembly version in the first/top most tab.
Whatever platform version you have in that class library should be consistent with the other projects in the solution.
This happens when you install some other nuget package (like Quartz.Unity) which depends on Quartz. While installing that other package if you select 'lowest' option for dependency then it would set Quartz 2.3.3.0 as dependency. However, you have Quartz 2.4.1 installed in your package. So you get the error.
Solution: While installing that other package select 'highest' option for dependency if you have highest version installed in your project.

Error using VS 2015 code analyzers

Using Visual Studio 2015 RTM, I have a .NET 4.0 class library project.
I've added the Microsoft.CodeAnalysis.FxCopAnalyzers NuGet package to the project. This results in the following Analyzers being listed for the project in Solution Explorer.
Microsoft.AnalyzerPowerPack.Common
Microsoft.AnalyzerPowerPack.CSharp
System.Runtime.Analyzers
System.Runtime.CSharp.Analyzers
System.Runtime.InteropServices.Analyzers
System.Runtime.InteropServices.CSharp.Analyzers
However in the Error List window, the following error appears:
Unable to load Analyzer assembly
C:\Dev\git\MySolution\packages\System.Runtime.Analyzers.1.0.0\analyzers\dotnet\cs\System.Runtime.Analyzers.dll
: Could not load file or assembly 'System.Runtime.Analyzers,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. Strong name validation failed. (Exception
from HRESULT: 0x8013141A)
(and similar for System.Runtime.CSharp.Analyzers and System.Runtime.InteropServices.Analyzers)
The first two analyzers do work correctly, but I'm not getting anything for the last four (probably related to the above errors).
Is there a way to get these to work, or is it possibly related to the project being .NET 4.0?
Thank you for reporting this issue. The System.Runtime.* analyzer assemblies uploaded to nuget are indeed only test-signed, and hence cause the assembly load failures. We are working uploading newer nuget packages for System.Runtime.Analyzers and System.Runtime.InteropServices.Analyzers which will have signed assemblies.
Meanwhile, you can get the non System.Runtime based FXCop analyzers by installing "Microsoft.AnalyzerPowerPack" from here: https://www.nuget.org/packages/Microsoft.AnalyzerPowerPack/. These do contain all signed assemblies and should work fine.
I'll post an update on this thread once we have uploaded signed System.Runtime analyzer packages.
Sorry for the inconvenience and thanks again for reporting it!
Regards,
Manish

Could not load assembly Microsoft.ReportViewer.Common, despite installing the prerequisites

So, I've got a C# windows workflow project that creates a report programmatically and emails it out. It works fine on my local machine, but putting it on a scheduler in a different machine generates the following error:
Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Based on other topics, I tried installing MICROSOFT® REPORT VIEWER 2012 RUNTIME from the following address: http://www.microsoft.com/en-us/download/details.aspx?id=35747. This didn't help. This was the overwhelmingly prevalent solution, but I'd love any other suggestions or advice.
The accepted answer pointed me in the right direction. However, didn't provide enough details for me to reach resolution. I wanted to add this as a comment to that answer but it was too long.
In my VS project, I had a reference to Microsoft.ReportViewer.WinForms version 12.0.0.0 and when deploying to another computer got the same error as present in this question. The key to the problem is a portion of the error:
The located assembly's manifest definition does not match the assembly
reference.
It is telling you that it found a DLL with the right name, but it is the wrong version. I had added a reference to Microsoft.ReportViewer.Common through the references dialog but I didn't catch that the only one listed in the "Extensions" section of the references dialog was for version 10.0.0.0. So of course it will deploy the wrong one if you are telling it to deploy the wrong one.
What you have to do is find the Microsoft.ReportViewer.Common.dll file with version 12.0.0.0 on your system and manually include a reference to that. For me it was in the following directory:
C:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.Common\12.0.0.0__89845dcd8080cc91\
Once I added that reference and set both DLLs to Copy Local in my VS project, then everything worked on the deployed machine.
Note: I did not require an installation of the Microsoft Report Viewer 2012 Runtime in order to have it work on the deployed machine. For any of you like me that were wanting to avoid any other installations during deployment.
try to add the dll files to the project from :
C:\Program Files\Microsoft Visual Studio 10.0\ReportViewer
add them to the bin folder after publishing the project

WAtin :Could not load file or assembly

Am getting this error : "Could not load file or assembly 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=db7cfd3acb5ad44e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"
I know many people already asked about it, but I've tried all the solutions suggested and still nothing!
Am Using VS2010, .NET framework version 4, and am trying to use WATin along with Web browser control.
I've tried all the suggested solutions here
WatiN System.IO.FileNotFoundException Interop.SHDocVw
This might be a bit of a long shot. Bring up your project properties and double check that your Target Framework (on the Application tab) is set to ".NET Framework 4", not ".NET Framework 4 Client Profile".
Right click on Interop.SHDocVw in the project references. Change Embed Interop Types to False and then set Copy Local to True. Worked for me.

Categories

Resources