不能再使用EnterpriseLibraryContainer,看看這是否有幫助。
的配置選項也仍然可用:
基本上你需要的NuGet包EnterpriseLibrary.TransientFaultHandling.Configuration
那麼你就需要在Web/App.config中更新喜歡的東西:
<configSections>
<section name="RetryPolicyConfiguration" type="Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Configuration.RetryPolicyConfigurationSettings, Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Configuration, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<section name="typeRegistrationProvidersConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.TypeRegistrationProvidersConfigurationSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<typeRegistrationProvidersConfiguration>
<clear />
<add sectionName="RetryPolicyConfiguration" name="RetryPolicyConfiguration" />
</typeRegistrationProvidersConfiguration>
<RetryPolicyConfiguration defaultRetryStrategy="Fixed Interval Retry Strategy"
defaultSqlConnectionRetryStrategy="Incremental Retry Strategy">
<incremental name="Incremental Retry Strategy" retryIncrement="00:00:01" initialInterval="00:00:01" maxRetryCount="10" />
<fixedInterval name="Fixed Interval Retry Strategy" retryInterval="00:00:01" maxRetryCount="10" />
<exponentialBackoff name="Backoff Retry Strategy" minBackoff="00:00:01" maxBackoff="00:00:30"
deltaBackoff="00:00:10" maxRetryCount="10" firstFastRetry="false"/>
</RetryPolicyConfiguration>
如果您得到像「retryInterval」屬性或「fastFirstRetry」這樣的運行時錯誤不是可識別的屬性,請嘗試使用「initialInterval」和「firstFastRetry」,它們已被重命名。供參考請看here。
在代碼級別,你會需要這樣的東西:
RetryPolicy retryPolicy;
try
{
retryPolicy = RetryPolicyFactory.GetDefaultSqlConnectionRetryPolicy();
}
catch (NullReferenceException)
{
throw new Exception("Unable to read transient fault handling behaviour from config, config section for TransientFaultHandling seems to be missing.");
}
return retryPolicy;
希望這有助於!
這確實令人沮喪。我試圖學會使用日誌塊,並有相同的問題。希望MS能很快解決這個問題。 – 2013-05-01 17:14:57