Unity load Error

May 8, 2012 at 11:37 AM
Edited May 8, 2012 at 11:39 AM

Parser Error Message: An error occurred creating the configuration section handler for unity: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047.


Thanks in Advance..


May 8, 2012 at 10:52 PM

This usually happens if assembly information is not correct (e.g. wrong version, strong name, etc.).

Can you post the configuration?

Randy Levy
Enterprise Library support engineer

May 9, 2012 at 3:56 AM

Actually , the application with the Unity is working fine .  In the NUnit test case, i am trying to use the Unity but it shows the above error.  Given the below unity configuration  in the App.config of the NUnit project.

<section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"  />

 <register name ="ILogManager" type ="AutoCompleteValidation.CrossCutting.Interfaces.ILogManager, AutoCompleteValidation.CrossCutting.Interfaces" mapTo ="AutoCompleteValidation.CrossCutting.LogManager, AutoCompleteValidation.CrossCutting" />
<register type ="AutoCompleteValidation.DataService.Interfaces.Common.IUseCase1DataService, AutoCompleteValidation.DataService.Interfaces" mapTo ="AutoCompleteValidation.DataService.Common.UseCase1DataService, AutoCompleteValidation.DataService" />

Code in the unit test method,

  UnityContainer container = new UnityContainer();
 Mock<ILogManager> logManagerMock = new Mock<ILogManager>();
 logManagerMock.Setup(r => r.Info(""));

Code in the application to read the unity configuration,

 using (IUnityContainer newInstance = new UnityContainer())
                    UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
                    _container = newInstance;




May 9, 2012 at 4:23 AM

I would guess that the type LogManager cannot be resolved.  Your code probably references the ILogManager interface but does not reference the concrete LogManager type (that is in the configuration file) so the AutoCompleteValidation.CrossCutting assembly is not deployed to the NUnity output folder (the same could apply to the UseCase1DataService).

Verify that all the required assemblies are deployed to the NUnit output folder.  You can troubleshoot the issue by using the Assembly Binding Log Viewer (fuslogvw.exe) -- it should show what exactly is failing and why.

Randy Levy
Enterprise Library support engineer