Does the Alias, Register tag support the ConfigSource Attribute?

Topics: Building and extending application blocks, General discussion
Jun 29, 2011 at 8:09 AM


With the developing continue, the Unity and the Container will getting bigger. Could I use the configsource attribute with the alias, register, unity tag?

such as:

<unity name="configsource">

        <alias configsource="interfacealias.config"/>

       <alias configsource="classalias.config"/>


       <register configsource="classregister.config"/>


Jun 29, 2011 at 8:43 AM
Edited Jun 29, 2011 at 8:55 AM

Yes you can use the configsource with unity but not with alias and register. I'm not sure why you need to put the alias and register on a seperate config since it will only contains a type. The disadvantage of this is you will create a lot of configs which may later be hard to maintain. The code below is an example of using configsource in unity:

in your Main Config:

 <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" />
<unity configSource="Unity.config" />
in Unity.config 
<unity xmlns="">
      <register type="DependencyInjection.Program+ISomeService, DependencyInjection" mapTo="DependencyInjection.Program+ImplementService, DependencyInjection">
          <param name="myObj" value=""></param>
Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Jun 30, 2011 at 9:40 AM

Thank you.