views:

18

answers:

2

This is kind of a follow to my other post about Unity (http://stackoverflow.com/questions/3998559/irepository-iservice-unity-in-an-asp-net-mvc-application-reference-question). Basically I'm trying to register a generic type in the web.config. I've read a few posts and this SEEMS like it is configured correctly.


<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
 <alias alias="IService" type="Porject.Service.IService`1, Porject.Service" />
 <alias alias="PropertyService" type="Porject.Service.PropertyService, Porject.Service"/>

 <container>
  <register type="IService[Property]" mapTo="PropertyService" />
 </container>
</unity>

But I get this error:

Server Error in '/' Application.

The type name or alias IService[Property] could not be resolved. Please check your configuration file and verify this type name. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The type name or alias IService[Property] could not be resolved. Please check your configuration file and verify this type name.

Source Error:

Line 33: Line 34: UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity"); Line 35: section.Configure(_container); Line 36: Line 37:

Source File: D:\Projects\Ex2\NCI\TREB\src\WebUI\UnityControllerFactory.cs Line: 35

A: 

There's no alias or namespace / assembly shortcuts for the type Property. Where is this type defined? Fix that and it should work.

Chris Tavares
A: 

A config file is meant to be read by humans thus don't make your life difficult. The following line is really hard to maintain

<alias alias="IService" type="Porject.Service.IService`1, Porject.Service" />
bakopanos costas