Thomas.Benz
Thomas.Benz

Reputation: 8599

Unity IoC - Deprecated method

Recently I have upgraded IoC assembly of Microsoft.Practices.Unity to version 3.0.1304.1 for .NET target 4.5. I do not have any compile errors when building my application. However, I keep seeing a VS code context warning like "deprecated method Microsoft.Practices.Unity.InjectedMembers" when I hover the mouse over "InjectedMembers" in the following code lines:

IUnityContainer container = new UnityContainer();

container.RegisterType<IRepository, Repository>(new HttpContextLifetimeManager<IRepository>())
                .Configure<InjectedMembers>()
                .ConfigureInjectionFor<Repository>(new InjectionConstructor(typeof(DbContext)));

So, what is the alternative method and its syntax I should use instead of the "InjectedMembers"?
Please help. Thank you in advance.

Upvotes: 0

Views: 1067

Answers (1)

seso
seso

Reputation: 187

i don`t know exactlay what changed between the versions. But this should do the same and solve the problem:

container.RegisterType<IRepository, Repository>(new HttpContextLifetimeManager<IRepository> (), new InjectionConstructor(typeof(DbContext)));

Upvotes: 1

Related Questions