Unity 3.0 config file issue

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am trying to initialize Unity 3.0 containers from the app.config file, as follows:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/>
</configSections>

<unity xmlns="http://schemas.microsoft.com/practices/2010/unity

<container>
<register type="Paychex.IP.Common.Interfaces.IExceptionHandler" mapTo="Paychex.IP.Common.ExceptionHandling.IPExceptionHandler
<property name="DefaultPolicy" value="Unhandled Policy" />
</register>
</container>
<container name="Test Container <register type="Paychex.IP.Common.Interfaces.IExceptionHandler" mapTo="Paychex.IP.Common.ExceptionHandling.IPExceptionHandler
<property name="DefaultPolicy" value="Unhandled Policy" />
</register>
</container>
</unity>
</configuration>
When I run code to attempt to ge a container and load the configuration, as shown: public static IUnityContainer GetIPContainer(string name)
{
IUnityContainer container = new UnityContainer();
container.AddNewExtension<Interception>();
try
{
if (name.Length > 0)
container.LoadConfiguration(name);
else
container.LoadConfiguration();
}
catch (Exception ex){ }
return container;
}
Every time, I get this exception:
InvalidOperationException
  • The type name or alias Paychex.IP.Common.Interfaces.IExceptionHandler could not be resolved. Please check your configuration file and verify this type name.
I have tried a whole bunch of things in the config file with no luck. In Code, it works fine to register the types, everything is referenced properly and in scope: // This should not be necessary in Code!
container.RegisterType<IExceptionHandler, IPExceptionHandler>();
Anyone seeing something stupid or noobie mistakes feel free to point them out.
Peter

View the full article
 
Back
Top