EDN Admin
Well-known member
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
container.RegisterType<IExceptionHandler, IPExceptionHandler>();
Anyone seeing something stupid or noobie mistakes feel free to point them out.
Peter
View the full article
<?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.
container.RegisterType<IExceptionHandler, IPExceptionHandler>();
Anyone seeing something stupid or noobie mistakes feel free to point them out.
Peter
View the full article