policy injection with unity

Oct 21, 2009 at 2:25 PM
Edited Oct 21, 2009 at 2:30 PM

hi i am starter for Unity and enterprise library...I am trying to inject policy injection ........

IDataStorage testDataStorage;

this .container.RegisterType<IDataStorage,TestDataStorage>();

taskDataStorage=this.container.Resolve<IDataStorage>();

taskDataStorage =PolicyInjection.Wrap<IDataStorage>(testDataStorage); /// this line is generating exception

//// Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ///////////

 

How am I suppose to inject policy ...........I just want to inject policy to the class want to put matching rule according to attribute type.......

Oct 21, 2009 at 11:42 PM

Is Microsoft.Practices.EnterpriseLibrary.Common.dll available to be loaded?

What does fuslogvw tell you about which DLL it's trying to load?

 

Oct 22, 2009 at 3:17 AM
ctavares wrote:

Is Microsoft.Practices.EnterpriseLibrary.Common.dll available to be loaded?

What does fuslogvw tell you about which DLL it's trying to load?

 

 

 protected override object DoGetInstance(Type serviceType, string key)
        {
            return _unityContainer.Resolve(serviceType, key);
        }   
////////////////////////Exception Displayed in above method .....Inside UnityServiceLocatorAdapter class //////////////////////
Resolution of the dependency failed, type = "Test.Views.TestView", name = "". Exception message is: The current build operation (build key Build Key[Test.Views.TestView, null]) failed: Object reference not set to an instance of an object. (Strategy type BuildPlanStrategy, index 3)
//////Code which raise exception//////
 this.container.RegisterType<IDataStorage, TaskDataStorage>();
            IDataStorage dataStorage= this.container.Resolve<IDataStorage>();
            IDataStorage dataStorage1=PolicyInjection.Wrap<IDataStorage>(dataStorage);/////////// line to generate issue

Thank you for the reply

Now I fixed the Commom.Dll issue then I get below exception

protected override object DoGetInstance(Type serviceType, string key)

        {

            return _unityContainer.Resolve(serviceType, key);

        }   

////////////////////////Exception Displayed in above method .....Inside UnityServiceLocatorAdapter class //////////////////////

 

Resolution of the dependency failed, type = "Test.Views.TestView", name = "". Exception message is: The current build operation (build key Build Key[Test.Views.TestView, null]) failed: Object reference not set to an instance of an object. (Strategy type BuildPlanStrategy, index 3)

 

//////Code which raise exception//////

 

 this.container.RegisterType<IDataStorage, TaskDataStorage>();

            IDataStorage dataStorage= this.container.Resolve<IDataStorage>();

            IDataStorage dataStorage1=PolicyInjection.Wrap<IDataStorage>(dataStorage);/////////// line which  generate Exception

 

Oct 22, 2009 at 12:49 PM

Hi I am again getting this exception

IDataStorage testDataStorage;

this .container.RegisterType<IDataStorage,TestDataStorage>();

testDataStorage=this.container.Resolve<IDataStorage>();

testDataStorage =PolicyInjection.Wrap<IDataStorage>(testDataStorage); /// this line is generating exception

//// Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ///////////

I guess 'Microsoft.Practices.EnterpriseLibrary.Common is available to load as I added it as reference. Please help me

 

 

Oct 22, 2009 at 4:54 PM
Edited Oct 22, 2009 at 5:00 PM

Hi

 IUnityContainer.AddNewExtension<

container = new UnityContainer()Interception>();

 configSource.GetSection(

IConfigurationSource configSource = ConfigurationSourceFactory.Create();

PolicyInjectionSettings settings = (PolicyInjectionSettings)PolicyInjectionSettings.SectionName);/////// In this line I am getting exception

 

Unrecognized element 'categories'. (C:\acharss_DgiDesktop\DGIT\DGIDesktop\DgiDesktop\DgiDesktop\NU.Desktop.Dgi.Desktop.Shell\bin\Debug\NU.Desktop.Dgi.Desktop.Shell.vshost.exe.Config line 28)

 if (settings != null)

{settings.ConfigureContainer(container, configSource);}