0

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.

1
  • Is your MyProjectsEnum in a namespace? May need to be fully qualified ContainingNamespace.MyProjectsEnum. I have no idea though really, just a notion. Commented Apr 7, 2009 at 1:20

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.