C # dll Microsoft DLL exception

I just added the Microsoft.VisualStudio.TestTools.UITesting link in my project, and I'm trying to use the ImageComparer` class, but I get an error when starting this

  private void Form1_Load(object sender, EventArgs e) { Image a = Image.FromFile(@"C:\Users\itapi\Desktop\a.png"); Image b = Image.FromFile(@"C:\Users\itapi\Desktop\b.png"); ImageComparer.Compare(a,b); } 

error

An unhandled exception of type 'System.TypeInitializationException' occurred in Microsoft.VisualStudio.TestTools.UITesting.dll

Additional Information: The type initializer for 'Microsoft.VisualStudio.TestTools.UITest.Extension.UITestUtilities' threw an exception.

Does anyone know what's wrong here?

this is the main process

System.TypeInitializationException: type initializer for 'Microsoft.VisualStudio.TestTools.UITest.Extension.UITestUtilities' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly "Microsoft.VisualStudio.TestTools.UITest.WindowsStoreUtility, Version = 12.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a 'or one of its dependencies. The system cannot find the specified file.
in Microsoft.VisualStudio.TestTools.UITest.Extension.UITestUtilities..cctor () --- The end of the internal trace of the exception stack is in Microsoft.VisualStudio.TestTools.UITest.Extension.UITestUtilities.CheckForNull (Object parameter, String parameterName) in Microsoft. VisualStudio.TestTools.UITesting.ImageComparer.CompareInternal (Image actualImageComparer.OutputImageComparer.OutputImageComparer.OutimageFrequently .VisualStudio.TestTools.UITesting.ImageComparer.Compare (Image actualImage, Image expectedImage) in WindowsFormsApplication4.Form1.Form1_Load (object sender, EventArgs e) in c: \ Users \ itapi \ OneDrive \ ?????? \ Visual Studio 2013 \ Projects \ WindowsFormsApplication4 \ W indowsFormsApplication4 \ Form1.cs: line 30

+5
source share
2 answers

Could not load file or assembly "Microsoft.VisualStudio.TestTools.UITest.WindowsStoreUtility ...

This is fully expected. This assembly was intended for use in Visual Studio only. It is present in the C: \ Program Files (x86) \ Microsoft Visual Studio 12.0 \ Common7 \ IDE \ PrivateAssemblies directory, completely out of the reach of your Winforms application. CLR will never find it.

The same is true for the Microsoft.VisualStudio.TestTools.UITesting.dll assembly, but you received a copy in the bin \ Debug directory because you referenced it.

These assemblies were intended only for creating unit tests that you run using the menu item Test> Run. The article is for MSDN to create coded user interface tests here.

You can copy the missing assembly with XCOPY in the post-build event . But using the integrated unit test function is by far the best and only decent way to get the minimum guarantee that it still works when upgrading the VS version.

+8
source

This question bothers me. Why focus on exception instead of problem? It seems you want to compare the images. Why not ask how to compare images? A quick search will give a lot of results, for example a quick comparison of bitmaps - C # . I was looking for c# compare images and that was the 10th link. Others before this also have a promise. What results do you want to get true / false, percentage match, only image and data mismatch exif ok, other?

Also, when I look at the documentation for ImageComparer.Compare on MSDN , the signature is different from the sample code in this question. The documentation seems poor in this regard regarding usage, and if it should be used from Visual Studio, as others have discussed.

+1
source

All Articles