C# TechTalk.Specflow.dll中的ConfigurationErrorsException

C# TechTalk.Specflow.dll中的ConfigurationErrorsException,c#,selenium,specflow,xunit,C#,Selenium,Specflow,Xunit,当我试图使用specflow执行我的功能文件时,我在 抛出新的ConfigurationErrorsException(“未设置数据提供程序节”) 上面说 System.Configuration.ConfigurationErrorsException类型的异常 在项目中发生,但未在代码中处理 // ///读取与配置集相关的配置 /// 私有静态void LogInitializer() { LogProviderConfiguration configSection=(LogProvide

当我试图使用specflow执行我的功能文件时,我在

抛出新的ConfigurationErrorsException(“未设置数据提供程序节”)

上面说

System.Configuration.ConfigurationErrorsException类型的异常 在项目中发生,但未在代码中处理

//
///读取与配置集相关的配置
/// 
私有静态void LogInitializer()
{
LogProviderConfiguration configSection=(LogProviderConfiguration)ConfigurationManager.GetSection(“LogProviders”);
if(configSection==null)
抛出新的ConfigurationErrorsException(“未设置数据提供程序节”);
_providerCollection=新的LogProviderCollection();
ProvidersHelper.InstanceProviders(configSection.Providers,_providerCollection,typeof(LogProviderBase));
_providerSettings=configSection.Providers;
if(_providerCollection[configSection.DefaultProviderName]==null)
抛出新的ConfigurationErrorsException(“未设置默认数据提供程序”);
_默认值=_providerCollection[configSection.DefaultProviderName];
var defaultSettings=_providerSettings[configSection.DefaultProviderName];
_default.SetParameters(defaultSettings.Parameters);
}

在specflow项目中似乎没有配置文件。请将app.confog文件添加到LogProviders部分,然后它就可以工作了

/// <summary>
/// Reads the configuration related to the set of configuration
/// </summary>
private static void LogInitializer()
{
    LogProviderConfiguration configSection = (LogProviderConfiguration)ConfigurationManager.GetSection("LogProviders");
    if (configSection == null)
   throw new ConfigurationErrorsException("Data provider section is not set.");


    _providerCollection = new LogProviderCollection();
    ProvidersHelper.InstantiateProviders(configSection.Providers, _providerCollection, typeof(LogProviderBase));

    _providerSettings = configSection.Providers;

    if (_providerCollection[configSection.DefaultProviderName] == null)
        throw new ConfigurationErrorsException("Default data provider is not set.");
    _default = _providerCollection[configSection.DefaultProviderName];
    var defaultSettings = _providerSettings[configSection.DefaultProviderName];

    _default.SetParameters(defaultSettings.Parameters);
}