简体   繁体   English

SpecFlow FeatureSetup引发System.Reflection.ReflectionTypeLoadException

[英]SpecFlow FeatureSetup throws System.Reflection.ReflectionTypeLoadException

SpecFlow will throw a System.Reflection.ReflectionTypeLoadException in the FeatureSetup method where it does not provide any information about the exception and will ask you to retrieve the LoaderExceptions property (error shown below). SpecFlow将在FeatureSetup方法中引发System.Reflection.ReflectionTypeLoadException,其中它不提供有关异常的任何信息,并会要求您检索LoaderExceptions属性(如下所示的错误)。 Setting a Debugging break at the beginning of the generated FeatureSetup method to look at the problem would not trigger the break. 在生成的FeatureSetup方法的开头设置调试中断以查看问题不会触发中断。 How can I find out the source of this problem? 如何找到此问题的根源?

Error: Unable to load one or more of the requested types. 错误:无法加载一种或多种请求的类型。 Retrieve the LoaderExceptions property for more information. 检索LoaderExceptions属性以获取更多信息。

Add a try/catch block around all of the code in the generated FeatureSetup method and add Console.WriteLine to output each LoaderException as shown below. 在生成的FeatureSetup方法中的所有代码周围添加一个try / catch块,并添加Console.WriteLine以输出每个LoaderException,如下所示。 The LoaderException Message(s) will then be displayed on your NUnit GUI screen when you run the test. 然后,当您运行测试时,LoaderException消息将显示在NUnit GUI屏幕上。 StackFlow link How to retrieve the LoaderException property? StackFlow链接如何检索LoaderException属性? was very helpful. 非常有帮助。

        try
        {
            testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
            TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "MyTest", null, ProgrammingLanguage.CSharp, ((string[])(null)));
            testRunner.OnFeatureStart(featureInfo);
        }
        catch (Exception e)
        {
            var typeLoadException = e as ReflectionTypeLoadException;
            var loaderExceptions = typeLoadException.LoaderExceptions;
            foreach (Exception le in loaderExceptions)
                Console.WriteLine("LoaderException Msg = {0}", le.Message);
        }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Sybase时AppDomain.CurrentDomain.GetAssemblies()引发System.Reflection.ReflectionTypeLoadException - AppDomain.CurrentDomain.GetAssemblies() throws System.Reflection.ReflectionTypeLoadException when using Sybase 未处理的异常:Unity3d中的System.Reflection.ReflectionTypeLoadException - Unhandled Exception: System.Reflection.ReflectionTypeLoadException in Unity3d 获取程序集中的类型(错误:System.Reflection.ReflectionTypeLoadException) - Get Types in assembly (error: System.Reflection.ReflectionTypeLoadException) coiniumServ在Windows上运行,在单声道运行时出现System.Reflection.ReflectionTypeLoadException失败。 - coiniumServ works on windows, fails on mono at runtime with System.Reflection.ReflectionTypeLoadException C# - 动态加载 DLL - System.Reflection.ReflectionTypeLoadException:无法加载一种或多种请求的类型 - C# - Loading DLL Dynamic - System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types 添加显示未处理的异常的Emgu.CV.World dll时:System.Reflection.ReflectionTypeLoadException - On Adding Emgu.CV.World dll showing Unhandled Exception: System.Reflection.ReflectionTypeLoadException Windows服务:抛出System.Reflection.ReflectionTypeLoadException并显示以下错误消息:无法加载一个或多个re - Windows Service: System.Reflection.ReflectionTypeLoadException was thrown with the following error message: Unable to load one or more of the re MahApps DLL的Reflection.ReflectionTypeLoadException - Reflection.ReflectionTypeLoadException for MahApps DLL Spring CodeConfig ScanAllAssemblies抛出ReflectionTypeLoadException - Spring CodeConfig ScanAllAssemblies throws a ReflectionTypeLoadException PropertieInfo的GetValue抛出TargetParameterCountException(System.Reflection) - GetValue of PropertieInfo throws TargetParameterCountException (System.Reflection)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM