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

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

问题描述

我只是说 Microsoft.VisualStudio.TestTools.UITesting 的refrence在我的项目,我尝试使用ImageComparer`类,但在运行此当我得到一个错误

 私人无效Form1_Load的(对象发件人,EventArgs五)
{
映象= Image.FromFile(@ C:\Users\itapi\Desktop\a.png);
图像B = Image.FromFile(@C:\Users\itapi\Desktop\b.png);
ImageComparer.Compare(A,B);
}



误差



< BLOCKQUOTE>

类型的'System.TypeInitializationException'
未处理的异常出现在Microsoft.VisualStudio.TestTools.UITesting.dll



其他信息:为
'Microsoft.VisualStudio.TestTools.UITest.Extension.UITestUtilities'
抛出异常的类型初始值




没有任何人有任何想法有什么不对吗?



这是innter错误时抛出




System.TypeInitializationException:为
'Microsoft.VisualStudio.TestTools.UITest.Extension.UITestUtilities'
的类型初始值引发了异常。 ---> System.IO.FileNotFoundException:未能
加载文件或程序
'Microsoft.VisualStudio.TestTools.UITest.WindowsStoreUtility,
版本= 12.0.0.0,文化=中性公钥= b03f5f7f11d50a3a'或
它的一个依赖。该系统找不到指定的文件搜索
。在
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestUtilities..cctor()
---内部异常堆栈跟踪的结尾 - - 在Microsoft.VisualStudio.TestTools.UITest.Extension.UITestUtilities.CheckForNull(对象
参数,字符串参数名称)在
Microsoft.VisualStudio.TestTools.UITesting.ImageComparer.CompareInternal(图片
actualImage ,图像expectedImage,ColorDifference argbTolerance,
形象和放大器; diffImage,布尔createOutImage)在
Microsoft.VisualStudio.TestTools.UITesting.ImageComparer.Compare(图片
actualImage,图像expectedImage,ColorDifference argbTolerance)在
Microsoft.VisualStudio.TestTools.UITesting.ImageComparer.Compare(图片
actualImage,图片expectedImage)在
WindowsFormsApplication4.Form1.Form1_Load(对象发件人,EventArgs五)
在C:\\ \\Users\itapi\OneDrive\ ?????? \Visual工作室
2013\Projects\WindowsFormsApplication4\WindowsFormsApplication4\Form1.cs:行
30



解决方案

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




这是完全的预期。该组件是为了只从的 的Visual Studio中使用。这是目前在C:\Program文件(x86)\Microsoft的Visual Studio 12.0\Common7\IDE\PrivateAssemblies目录,相当出从Winforms应用程序够不到的地方。 CLR将永远也找不到它。



同样适用于装配Microsoft.VisualStudio.TestTools.UITesting.dll真实的,但你在你的bin\Debug目录中有一个副本,因为你引用它。



这些组件都只是为了用于创建单元测试,你的测试运行的那种>运行菜单项。在MSDN如何做的文章用于创建编码的UI测试是这里



您可以在后生成事件复制与 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天全站免登陆