Constructor Paramater of IEnumerable[type] with array

Jul 21, 2011 at 2:47 PM

I'm trying to correctly implement the design time configuration of a type that requires a paramater of IEnumerable< previously mapped type >, with the array dependencies added.  This is the code I have:

<alias alias="PolicyProcessor" type="Clarity.Services.PolicyProcessor, Foo.Assembly" />
<alias alias="DecisionPolicy" type="Clarity.Core.DecisionPolicies.DecisionPolicy, Foo.Assembly" />

alias alias="DecisionPolicyArray" type="System.Collections.Generic.IEnumerable`1[[DecisionPolicy, Foo.Assembly]], System.Collections"/>

type type="DecisionPolicy" mapTo="AddressDiscrepancyPolicy" name="AddressDiscrepancy" />
type type="DecisionPolicy" mapTo="ChargeOffPolicy" name="ChargeOff" />

type type="PolicyProcessor" name="MinorPolicyProcessor">
lifetime type="singleton" />
param name="policyList" type="DecisionPolicyArray">
<dependency name="ChargeOff"></dependency>
dependency name="DelinquentLoan"></dependency>

If I run this, I get the error: The type name or alias DecisionPolicyArray could not be resolved. Please check your configuration file and verify this type name.

I think I'm not formatting the IEnumarable alias correctly. If I change the alias to use a simple array instead of an IEnumerable,
I get an error that says the Policy Processor doesn't accept a paramater named policy List.

But it certainly does, of type IEnumerable<DecisionPolicy>, which is what I need to give it.
Jul 22, 2011 at 8:59 AM

Try to change the below code:
<alias alias="DecisionPolicyArray" type="System.Collections.Generic.IEnumerable`1[[DecisionPolicy, Foo.Assembly]], System.Collections"/> 
<alias alias="DecisionPolicyArray" type="System.Collections.Generic.IEnumerable`1[DecisionPolicy], System.Collections"/> 
and see if this works?

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us
Sep 19, 2011 at 7:05 AM

Did you ever figure this out, as I am having this exact issue and can't seem to get it resolved.  In Unity 1.2 it all works fine, I assume it does some conversion of an array to an IEnumerable type, but in Unity 2.0 nothing I've tried works.

Sep 23, 2011 at 7:08 AM
Edited Sep 23, 2011 at 7:16 AM


The namespace used for the IEnumerable is incorrect. Also try to specify the fully qualified assembly name of the IEnumerable something like:

System.Collections.Generic.IEnumerable`1[[Clarity.Core.DecisionPolicies.DecisionPolicy, Foo.Assembly]], mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089

For more details, kindly refer to this link. Also, kindly disregard my earlier post. Hope this helps :)


Noel Angelo Bolasoc
Avanade Software
Avanade, Inc.
Contact Us