如何诊断Resharper单元测试运行程序“无法加载一种或多种请求的类型”,错误 [英] How to diagnose Resharper Unit Test Runner "Unable to load one or more of the requested types" error

查看:142
本文介绍了如何诊断Resharper单元测试运行程序“无法加载一种或多种请求的类型”,错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用Resharper单元测试运行器运行或调试单元测试时,弹出一个对话框,提示单元测试运行器无法运行测试-无法加载一个或多个请求的类型。检索LoaderExceptions属性用于更多信息:

When I run or debug my unit tests using Resharper Unit Test Runner, I get a dialog popping up that says "Unit Test Runner failed to run tests - Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information":

现在我已尝试重建,清理,手动删除文件夹,Visual Studio重新启动,硬件重新启动,在输出/调试窗口中查找,以及晚上启用R#内部模式,以便我可以看到它的日志(据我所知写入%Temp%\JetLogs),但是这些都没有解决它或提供任何线索。我已经尝试过调试 R#,但是在调试器遇到任何异常之前,对话框再次弹出。

Now I have tried rebuilds, cleans, manually deleting folders, visual studio restarts, hardware restarts, looking in output/debug windows, and evening enabling R# "internal" mode so that I can see it's logs (written to %Temp%\JetLogs as I understand), but none of that resolves it or gives any clues at all. I have tried "debugging" R# but again the dialog pops up before the debugger hits any exceptions.

我该怎么解决这个问题?

How the hell am I supposed to resolve this? It's extremely annoying!

我正在使用:


  • R#2016.1。 2

  • NUnit 3.2.1

  • Visual Studio 2015更新2(14.0.25123)

推荐答案

我最终用一种非常简单的方法对此进行了诊断:

I ended up diagnosing this with a fairly simple method:

我转换了单位从类库测试程序集到控制台应用程序,并添加了Main入口点(如下所示)。我在其中迭代所有我希望会导致所有类型的程序集类型。依赖的程序集被加载,这将揭示任何加载异常。是的,它奏效了。它很快抛出了 System.Reflection.ReflectionTypeLoadException ,它是错误消息无法加载一个或多个...的规范来源。在调试器中,我可以检查 LoaderExceptions 属性,该属性告诉我潜在的问题是什么。

I converted my unit test assembly from a class library into a console application and added a Main entry point (shown below). Within there I iterate all of the assemblies types which I hoped would cause all types & dependent assemblies to be loaded, which would reveal any load exceptions. And yes it worked. It quickly threw a System.Reflection.ReflectionTypeLoadException which is the canonical source of the error message "Unable to load one or more...". In the debugger I could examine the LoaderExceptions property which told me what the underlying problem was.

public class Program
{ 
    public static void Main(string[] args)
    {
        var types = Assembly.GetExecutingAssembly().GetTypes();
    }
}

这篇关于如何诊断Resharper单元测试运行程序“无法加载一种或多种请求的类型”,错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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