I'm working at a ASP.NET Webforms project and is using Unity for DI. This project also use DevExpress ASP.NET Ajax Controls.
Now we have run into problem and it seems to be a conflict between DevExpress and Unity.
This is the Unity configuration
[assembly: WebActivator.PostApplicationStartMethod(typeof(Sales.Web.App_Start.UnityWebFormsStart), "PostStart")]
namespace Sales.Web.App_Start
{
/// <summary>
/// Startup class for the Unity.WebForms NuGet package.
/// </summary>
internal static class UnityWebFormsStart
{
/// <summary>
/// Initializes the unity container when the application starts up.
/// </summary>
/// <remarks>
/// Do not edit this method. Perform any modifications in the
/// <see cref="RegisterDependencies" /> method.
/// </remarks>
internal static void PostStart()
{
IUnityContainer container = new UnityContainer();
HttpContext.Current.Application.SetContainer(container);
RegisterDependencies(container);
}
/// <summary>
/// Registers dependencies in the supplied container.
/// </summary>
/// <param name="container">Instance of the container to populate.</param>
private static void RegisterDependencies(IUnityContainer container)
{
// TODO: Add any dependencies needed here
container
.RegisterType<IDbFactory, DbFactory>(new HierarchicalLifetimeManager())
.RegisterType(typeof(IDbProxy<>), typeof(DbProxy<>))
.RegisterType<IErpData, ErpData>(new HierarchicalLifetimeManager())
.RegisterType<ICaseData, CaseData>(new HierarchicalLifetimeManager())
.RegisterType<ICaseCauseData, CaseCauseData>(new HierarchicalLifetimeManager())
.RegisterType<ICaseHandler, CaseHandler>(new HierarchicalLifetimeManager());
}
}
}
Any of this Unity configuration has nothing to do with the DevExpress controls, but i think it hooks up the HttpContext object.
And this error appears only when i use the TabControl from DevExpress, all other controls works well.
See the attached image that describe the error message more in detail.