1
我在VS 2010中有一个c#类库项目,它输出一个dll。我在我的解决方案中添加了一个可执行项目,我需要从头开始,以便调试我的dll。我没有具有app.config的主机应用程序。我可以在我的类库项目中使用Enterprise Libray(特别是异常处理)吗?如果是的话,我怎样才能定义异常处理策略,因为没有app.config?c#类库项目中的企业库5.0
谢谢!
我在VS 2010中有一个c#类库项目,它输出一个dll。我在我的解决方案中添加了一个可执行项目,我需要从头开始,以便调试我的dll。我没有具有app.config的主机应用程序。我可以在我的类库项目中使用Enterprise Libray(特别是异常处理)吗?如果是的话,我怎样才能定义异常处理策略,因为没有app.config?c#类库项目中的企业库5.0
谢谢!
您可以使用Fluent Configuration API与企业库5
用方面Exception Handling。 (来自msdn)
var builder = new ConfigurationSourceBuilder();
builder.ConfigureExceptionHandling()
.GivenPolicyWithName("MyPolicy")
.ForExceptionType<NullReferenceException>()
.LogToCategory("General")
.WithSeverity(System.Diagnostics.TraceEventType.Warning)
.UsingEventId(9000)
.WrapWith<InvalidOperationException>()
.UsingMessage("MyMessage")
.ThenNotifyRethrow();
var configSource = new DictionaryConfigurationSource();
builder.UpdateConfigurationWithReplace(configSource);
EnterpriseLibraryContainer.Current
= EnterpriseLibraryContainer.CreateDefaultContainer(configSource);