TechTalk.Specflow.dll中的ConfigurationErrorsException

时间:2019-01-02 03:27:44

标签: c# selenium specflow xunit

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

处出现异常

throw new ConfigurationErrorsException("Data provider section is not set.");

其中

  

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

/// <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);
}

1 个答案:

答案 0 :(得分:1)

看来您在specflow项目中没有配置文件。请在LogProviders部分添加app.confog文件,然后它应该可以工作。