Could not load type error related to ReliableSqlConnection

Topics: Transient Fault Handling Application Block ("Topaz")
Nov 5, 2014 at 3:01 PM
Hi

If possible I was wondering if anybody could help me with this issue. I hope it's an easy fix. I have been advised to utilise transient fault handling. I have been successful in using a retry policy for sql commands but I have been unable to get the ReliableSqlConnection to work. I am getting the following error:

___An exception of type 'System.TypeLoadException' occurred in Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.dll but was not handled in user code

Additional information: Could not load type 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer' from assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.___

Please could you advise how I can fix this issue. It builds fine but I get this error when the ReliableSqlConnection class is actually used. I get the feeling I don't have the right nuget packages. The ones I have installed (probably too many) are...

<package id="EnterpriseLibrary.Common" version="6.0.1304.0" targetFramework="net45" />
<package id="EnterpriseLibrary.Data" version="6.0.1304.0" targetFramework="net45" />
<package id="EnterpriseLibrary.Data.SqlCe" version="6.0.1304.0" targetFramework="net45" />
<package id="EnterpriseLibrary.TransientFaultHandling" version="6.0.1304.0" targetFramework="net45" />
<package id="EnterpriseLibrary.TransientFaultHandling.Caching" version="6.0.1304.0" targetFramework="net45" />
<package id="EnterpriseLibrary.TransientFaultHandling.Configuration" version="6.0.1304.0" targetFramework="net45" />
<package id="EnterpriseLibrary.TransientFaultHandling.Data" version="6.0.1304.1" targetFramework="net45" />
<package id="EnterpriseLibrary.TransientFaultHandling.ServiceBus" version="6.0.1304.0" targetFramework="net45" />
<package id="EnterpriseLibrary.TransientFaultHandling.WindowsAzure.Storage" version="6.0.1304.1" targetFramework="net45" />
<package id="EnterpriseLibrary.WindowsAzure.TransientFaultHandling" version="5.1.1212.0" targetFramework="net45" />
<package id="Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.ServiceBus" version="6.0.1304.0" targetFramework="net45" />
<package id="Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.ServiceBus.dll" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Web.RedisSessionStateProvider" version="1.1.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Caching" version="2.4.0.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="1.7.0.3" targetFramework="net45" />
<package id="StackExchange.Redis.StrongName" version="1.0.371" targetFramework="net45" />
<package id="TransientFaultHandling" version="1.0.4" targetFramework="net45" />
<package id="TransientFaultHandling.Core" version="5.1.1209.1" targetFramework="net45" />
<package id="WindowsAzure.ServiceBus" version="1.8.0.0" targetFramework="net45" />

As a bit of background I am using a Windows 8 machine, Visual Studio 2013, .Net Framework 4.5.1. The project I am trying to use Transient Fault Handling in is a simple class library project.

Thanks

Alex
Nov 6, 2014 at 2:54 AM
The exception mentions trying to find EnterpriseLibraryContainer, which existed in version 5 but was removed in version 6. The list of packages has version 5 listed as well.

I would remove the version 5 packages and ensure that the configuration files are referencing the version 6 assemblies.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Nov 8, 2014 at 10:06 PM
Hi Randy

Thank you for your reply. I have removed the version 5 package that I was using however this presents a different problem. My project I think has the right references but when I try using these references they are unrecognised so my program won't even build. This was why I added the version 5 package in the first place. Do you know what might cause this?

Thanks

Alex
Nov 8, 2014 at 10:44 PM
What version of .NET are you targeting? Version 6 requires minimum .NET 4.5 -- perhaps you are targeting .NET 4?

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Nov 8, 2014 at 10:53 PM
Hi Randy

Thanks again - It is .NET 4.5 however this is a project that I had previously written for an earlier version of .NET is it possible this is the problem?

Thanks

Alex
Nov 11, 2014 at 12:35 AM
To me it still sounds like a version issue -- perhaps double check all of the assemblies to ensure they got upgraded. if you don't find anything, a sample solution might shed some light on the issue.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to