14

Enterprise Library 6.0 を使用すると、次のコードでこのエラーが発生します。

bool rethrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy1")

「SetExceptionManager メソッドを使用して、ExceptionPolicy クラスに ExceptionManager を設定する必要があります。」

Enterprise Library 5.0 では、次のコードが機能しました。

public static bool HandleException(Exception exception, string PolicyName)
{
    ExceptionManager exManager = EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>();
    ExceptionPolicy.SetExceptionManager(exManager);
    bool rethrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy1");
    return reThrow;
}

しかし、Enterprise Library 6.0 では EnterpriseLibraryContainer クラスが見つかりません。ExceptionManager のインスタンスを取得したい。この問題を解決するにはどうすればよいですか?

4

3 に答える 3

3

私もこの問題に直面しましたが、今ではこれを解決しました。Application_Start()そのため、Global.asaxファイル内の次のコードを設定することもできます。

IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory());
if (configurationSource.GetSection(LoggingSettings.SectionName) != null)
Logger.SetLogWriter(new LogWriterFactory(configurationSource).Create());
ExceptionPolicy.SetExceptionManager(new ExceptionPolicyFactory(configurationSource).CreateManager());
于 2017-04-03T10:01:19.963 に答える