tags:

views:

976

answers:

1

Currently I am trying to use a config file to give Unity Framework information that looks like this...

<configuration>
<unity>
 <typeAliases>
  <typeAlias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager,   Microsoft.Practices.Unity, Culture=neutral, Version=1.1.0.0,   PublicKeyToken=31bf3856ad364e35" />
 </typeAliases>
 <containers>
   <container>
     <types>  
       <type type="Common.ISharedConfiguration, Common, Version=3.1.0.0, Culture=neutral,  PublicKeyToken=1111111111111111" mapTo="Common.SharedConfigurationManager, Common, Version=3.1.0.0, Culture=neutral, PublicKeyToken=1111111111111111">
         <lifetime type="singleton" />
         <typeConfig  extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement, Microsoft.Practices.Unity.Configuration, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
           <constructor>
             <param name="OurEnumChoice" parameterType="MyProjectsEnum" >
               <value value="MyProjectsEnum.OurFirstConstant" type="MyProjectsEnum"/> 
             </param>
           </constructor> 
         </typeConfig>
       </type>
     </types>
   </container>
 </containers>
</unity>
</configuration>

If I choose something like System.String and have my concrete class have a construtor of string this config file info for Unity works great. The moment I choose to use an Enum instead of string Unity throws an error like this...

Could not load type MyProjectsEnum from assembly Microsoft.Practices.Unity.Configuration, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf33856ad364e35

I think I need an understanding of what I can pass as an understood type by Unity beyond simple types through this configuration process.

+2  A: 

You need to specify fully qualified type name for both 'parameterType' and 'type' attributes. Much the same you did for 'typeAlias' node. By default, Unity looks up its own assembly for unqualified types.