XML config changes in Unity 2.0

Topics: Prism v4 - WPF 4
Nov 8, 2011 at 1:56 PM

Hi everybody,

we've just upgrade a project from prism 2.0 to prism 4.0, and we're having problems with Unity. Apparently there's several changes in unity 2.0 container XML configuration as we get as our first error " Unrecognized element 'typeConfig' ". Here is the code:

//----------------------- App.config

<configSections>

<section name="runDataParserConfiguration" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" />

</configSections>

<runDataParserConfiguration>

<typeAliases>

<typeAlias alias="IRunDataDispatcher" type="RunDataParser.Interface.IRunDataDispatcher, RunDataParser.Interface" />

<typeAlias alias="IRunDataParser" type="RunDataParser.Interface.IRunDataParser, RunDataParser.Interface" />

<typeAlias alias="IRunDataParserArray" type="RunDataParser.Interface.IRunDataParser[], RunDataParser.Interface" />

<typeAlias alias="Dispatcher" type="RunDataParser.Common.Dispatcher, RunDataParser.Common" />

<typeAlias alias="Parser1" type="RunDataParser.Parser1, RunDataParser" />

<typeAlias alias="Parser2" type="RunDataParser.Parser2, RunDataParser" />

<typeAlias alias="Parser3" type="RunDataParser.Parser3,RunDataParser" />

<typeAlias alias="Parser4" type="RunDataParser.Parser4, RunDataParser" />

<typeAlias alias="Parser5" type="RunDataParser.Parser5, RunDataParser" />

<typeAlias alias="Parser6" type="RunDataParser.Parser6, RunDataParser" />

<typeAlias alias="Parser7" type="RunDataParser.Parser7, RunDataParser" />

<typeAlias alias="Parser8" type="RunDataParser.Parser8, RunDataParser" />

<typeAlias alias="Parser9" type="RunDataParser.Parser9, RunDataParser" />

</typeAliases>

<containers>

<container>

<types>

<type type="IRunDataParser" mapTo="Parser1" name="parser1" />

<type type="IRunDataParser" mapTo="Parser2" name="parser2" />

<type type="IRunDataParser" mapTo="Parser3" name="parser3" />

<type type="IRunDataParser" mapTo="Parser4" name="parser4" />

<type type="IRunDataParser" mapTo="Parser5" name="parser5" />

<type type="IRunDataParser" mapTo="Parser6" name="parser6" />

<type type="IRunDataParser" mapTo="Parser7" name="parser7" />

<type type="IRunDataParser" mapTo="Parser8" name="parser8" />

<type type="IRunDataParser" mapTo="Parser9" name="parser9" />

<type type="IRunDataDispatcher" mapTo="Dispatcher" name="runDataDispatcher" />

<type type="Presentation.RawDataManagement.Wrapper.ParserDispatcherWrapper, RawDataManagement">

<typeConfig>

<constructor>

<param name="runDataDispatcher" parameterType="Dispatcher" />

<param name="runDataParsers" parameterType="IRunDataParserArray">

<array>

<dependency name="parser1" />

<dependency name="parser2" />

<dependency name="parser3" />

<dependency name="parser4" />

<dependency name="parser5" />

<dependency name="parser6" />

<dependency name="parser7" />

<dependency name="parser8" />

<dependency name="parser9" />

</array>

</param>

</constructor>

</typeConfig>

</type>

</types>

</container>

</containers>

</containers>

 

</runDataParserConfiguration>

//----------------------------------------------------

I commented typeConfig node and got the error "No valid attributes were found to construct the value for the parameter runDataDispatcher. Please check configuration files."

After that and doing some research I removed parameterType attributes but this didn't work.

I commented typeAliases node and change typeAlias nodes to alias, also commented types node (under <container> node) and chage its child nodes type to register. Non of this worked. There's somebody that could give us a hand?, any anwser would be very much appreciated.

Thanks in advance

Developer
Nov 8, 2011 at 4:54 PM

Hi,

As this is mostly specific to Unity, you might find better support for this in the Unity forum:

Thanks for your understanding,

Damian Cherubini
http://blogs.southworks.net/dcherubini

Nov 9, 2011 at 11:07 AM

Finally we did it and the code now looks like (hope this can help somebody):

 <unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
    <alias alias="IRunDataDispatcher" type="RunDataParser.Interface.IRunDataDispatcher, RunDataParser.Interface" />
    <alias alias="IRunDataParser" type="RunDataParser.Interface.IRunDataParser, RunDataParser.Interface" />
    <alias alias="IRunDataParserArray" type="RunDataParser.Interface.IRunDataParser[], RunDataParser.Interface" />
    <alias alias="Dispatcher" type="RunDataParser.Common.Dispatcher, RunDataParser.Common" />
    <alias alias="Parser1" type="RunDataParser.Parser1, RunDataParser" />
    <alias alias="Parser2" type="RunDataParser.Parser2, RunDataParser" />
    <alias alias="Parser3" type="RunDataParser.Parser3,RunDataParser" />
    <alias alias="Parser4" type="RunDataParser.Parser4, RunDataParser" />
    <alias alias="Parser5" type="RunDataParser.Parser5, RunDataParser" />
    <alias alias="Parser6" type="RunDataParser.Parser6, RunDataParser" />
    <alias alias="Parser7" type="RunDataParser.Parser7, RunDataParser" />
    <alias alias="Parser8" type="RunDataParser.Parser8, RunDataParser" />
    <alias alias="Parser9" type="RunDataParser.Parser9, RunDataParser" />
    <container name="parsers">
      <register type="IRunDataParser" mapTo="Parser1" name="parser_1" />
      <register type="IRunDataParser" mapTo="Parser2" name="parser_2" />
      <register type="IRunDataParser" mapTo="Parser3" name="parser_3" />
      <register type="IRunDataParser" mapTo="Parser4" name="parser_4" />
      <register type="IRunDataParser" mapTo="Parser5" name="parser_5" />
      <register type="IRunDataParser" mapTo="Parser6" name="parser_6" />
      <register type="IRunDataParser" mapTo="Parser7" name="parser_7" />
      <register type="IRunDataParser" mapTo="Parser8" name="parser_8" />
      <register type="IRunDataParser" mapTo="Parser9" name="parser_9" />
      <register type="IRunDataDispatcher" mapTo="Dispatcher" name="runDataDispatcher" />
      <register type="Presentation.RawDataManagement.Wrapper.ParserDispatcherWrapper, RawDataManagement">
        <constructor>
          <param name="runDataDispatcher">
            <dependency type="Dispatcher" />
          </param>
          <param name="runDataParsers">
            <array>
              <dependency type="Parser1" />
              <dependency type="Parser2" />
              <dependency type="Parser3" />
              <dependency type="Parser4" />
              <dependency type="Parser5" />
              <dependency type="Parser6" />
              <dependency type="Parser7" />
              <dependency type="Parser8" />
              <dependency type="Parser9" />
            </array>
          </param>
        </constructor>
      </register>
    </container>
  </unity>

Thanks for your answer anyway!

Developer
Nov 9, 2011 at 12:04 PM
Edited Nov 9, 2011 at 12:26 PM

Hi,

Thank you for sharing this with the rest of the community!

Guido Leandro Maliandi 
http://blogs.southworks.net/gmaliandi