Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UnityContainer() LoadConfiguration not found

I have this code:

1: IUnityContainer container = new UnityContainer();
2: container.LoadConfiguration();

Line 1 works, but line 2 not. LoadConfiguration is not found as a member. I think, i have register all unity-dlls. Why is LoadConfiguration() not found?

like image 834
Jens O Avatar asked May 01 '12 19:05

Jens O


3 Answers

I believe in the latest version of Unity 5.9.3, Microsoft.Practices.Unity dlls are not part of the nuget. You'd have to install another package from nuget 'Unity.Configuration'. Its an open source package offered by Unity. As of today, Unity Configuration latest version is 5.9.0.

like image 139
HarshitGindra Avatar answered Nov 16 '22 06:11

HarshitGindra


Not only

Unity.Configuration package should be installed

but also

using Microsoft.Practices.Unity.Configuration;

should be declared at top of the cs file.

like image 26
Epic Chen Avatar answered Nov 16 '22 06:11

Epic Chen


LoadConfiguration() is not a member of IUnityContainer. You must be thinking of some other class or interface. Perhaps this one?

IUnityContainer is in the Microsoft.Practices.Unity namespace, but the LoadConfiguration() extension method lives in the Microsoft.Practices.Unity.Configuration namespace. Have you added that namespace to your code?

like image 21
Robert Harvey Avatar answered Nov 16 '22 07:11

Robert Harvey