c#dll微软dll异常 [英] c# dll microsoft dll exception

查看:323
本文介绍了c#dll微软dll异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在我的项目中添加了 Microsoft.VisualStudio.TestTools.UITesting 的引用,我尝试使用ImageComparer类,但是当运行此

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

错误是



< blockquote>

Microsoft.VisualStudio.TestTools.UITesting.dll中发生类型为'System.TypeInitializationException'
的未处理异常



其他信息:
'Microsoft.VisualStudio.TestTools.UITest.Extension.UITestUtilities'
的类型初始化程序抛出异常。



$ b $有没有人有任何想法这里有什么问题?



这是一个毫无价值的空白


System.TypeInitializationException:
'Microsoft.VisualStudio.TestTools.UITest.Extension.UITestUtilities'
的类型初始化程序抛出异常。 ---> System.IO.FileNotFoundException:无法
加载文件或程序集
'Microsoft.VisualStudio.TestTools.UITest.WindowsStoreUtility,
Version = 12.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或
其依赖关系之一。系统找不到指定的文件。


Microsoft.VisualStudio.TestTools.UITest.Extension.UITestUtilities..cctor()
---内部异常结束堆栈跟踪 - - 在Microsoft.VisualStudio.TestTools.UITest.Extension.UITestUtilities.CheckForNull(Object
参数,String parameterName)at
Microsoft.VisualStudio.TestTools.UITesting.ImageComparer.CompareInternal(Image
actualImage ,$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
Microsoft.VisualStudio.TestTools.UITesting.ImageComparer.Compare(Image
actualImage,Image expectedImage)at
WindowsFormsApplication4.Form1.Form1_Load(Object sender,EventArgs e)
in c: \\Users\itapi\OneDrive\ ???? \Visual Studio
2013 \P rojects\WindowsFormsApplication4\WindowsFormsApplication4\Form1.cs:line
30



解决方案

blockquote>

无法加载文件或程序集Microsoft.VisualStudio.TestTools.UITest.WindowsStoreUtility ...




Visual Studio中的。它存在于C:\Program Files(x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies目录中,远远不能满足您的Winforms应用程序的需求。 CLR将永远不会找到它。



对于Microsoft.VisualStudio.TestTools.UITesting.dll程序集也是如此,但是您的bin \Debug目录中有一个副本,因为你引用它。



这些程序集只是用来创建单元测试,你使用Test> Run菜单项运行的类型。用于创建编码UI测试的MSDN how-to文章在这里



您可以在后期制作事件中使用 XCOPY复制缺少的程序集。但是使用集成的单元测试功能当然是最好的,而且只有当您更新VS版本时,才能获得最小的保证,这仍然有效。


i just added the refrence of Microsoft.VisualStudio.TestTools.UITesting in my project and i try to use the ImageComparer` class but i get an error when running 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);
    }

the error is

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 has any idea what's wrong here?

this is the innter excpetion

System.TypeInitializationException: The 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 file specified.
at Microsoft.VisualStudio.TestTools.UITest.Extension.UITestUtilities..cctor() --- End of inner exception stack trace --- at Microsoft.VisualStudio.TestTools.UITest.Extension.UITestUtilities.CheckForNull(Object parameter, String parameterName) at Microsoft.VisualStudio.TestTools.UITesting.ImageComparer.CompareInternal(Image actualImage, Image expectedImage, ColorDifference argbTolerance, Image& diffImage, Boolean createOutImage) at Microsoft.VisualStudio.TestTools.UITesting.ImageComparer.Compare(Image actualImage, Image expectedImage, ColorDifference argbTolerance) at Microsoft.VisualStudio.TestTools.UITesting.ImageComparer.Compare(Image actualImage, Image expectedImage) at WindowsFormsApplication4.Form1.Form1_Load(Object sender, EventArgs e) in c:\Users\itapi\OneDrive\??????\Visual Studio 2013\Projects\WindowsFormsApplication4\WindowsFormsApplication4\Form1.cs:line 30

解决方案

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

That's entirely expected. This assembly was meant to only be used from within Visual Studio. It is present in the C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies directory, quite out of reach from your Winforms app. The CLR will never find it.

Same is true for the Microsoft.VisualStudio.TestTools.UITesting.dll assembly but you got a copy in your bin\Debug directory because you referenced it.

These assemblies were only meant to be used to create unit tests, the kind that you run with the Test > Run menu item. The MSDN how-to article for creating coded UI tests is here.

You can copy the missing assembly with XCOPY in a post build event. But using the integrated unit test feature is certainly best and the only decent way to get a minimal guarantee that this still works when you update the VS version.

这篇关于c#dll微软dll异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆