Using Unity:Interception W/Prism:Template Help......

Nov 7, 2012 at 2:27 AM


USING: VS2010 Pro, Prism Template 1.0

Created a project using the template and trying to implement Interception, but I get this Exception when executing the RegisterServices() function:

        private void RegisterServices()
            // Indicate to unity that we know what to do with an IClientRegistrationService interface
                .RegisterType<IClientRegistrationService, ClientRegistrationService>() 
                .RegisterType<IEnglishTurahService, EnglishTurahService>(new ContainerControlledLifetimeManager())
                .RegisterType<IExcelDataRepository, ExcelDataRepository>(new ContainerControlledLifetimeManager());

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

All projects use the package version of unity under the project folder .....\packages\Unity.2.1.505.0\lib\NET35, but when trying to use the unity Interception from either the downloaded Prism source or .NET Enterprise Library 5, I get this exception.

Also during the build output window, I get this message:

------ Build started: Project: PrismApplication2, Configuration: Debug x86 ------

Consider app.config remapping of assembly "Microsoft.Practices.Unity, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "2.0.414.0" [C:\Program Files (x86)\Microsoft Enterprise Library 5.0\Bin\Microsoft.Practices.Unity.dll] to Version "2.1.505.0" [C:\Users\nasheayahu\Documents\Visual Studio 2010\Projects\PrismApplication2\packages\Unity.2.1.505.0\lib\NET35\Microsoft.Practices.Unity.dll] to solve conflict and get rid of warning.

It only does this when I add the container.AddNewExtension<Interception>();.  I'm only guessing that I'll have to remove all package references and use the Enterprise or the down loaded Prism 4.1 version?

Thanks for your help!...

Nov 8, 2012 at 3:23 PM

Prism 4.1 references Unity 2.0.414.0.  That is why you are receiving that error.  Use a binding redirect to use a later build (e.g. Unity 2.1 AKA build 2.1.505.0):

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
            <bindingRedirect oldVersion="" newVersion="2.1.505.0"/>

Randy Levy
Enterprise Library support engineer