hi guys,
i'm trying to use unity to resolve an generic instance of the IChannelFactory<ISomeType>
to create channels to a service i have written.
The problem is that the concrete version of this class ChannelFactory<ISomeType>
takes the concrete type System.ServiceModel.Channels.Binding
as a parameter.
My first problem was that it could not find System.ServiceModel
but i resolved that by putting the super fully qualified name (including version number etc). So now i can break into the code but it blows up when i try to resolve an IChannelFactory
My config is as such:
<!--binding-->
<type name="customerBinding" type="System.ServiceModel.BasicHttpBinding, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<typeConfig extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement, Microsoft.Practices.Unity.Configuration">
<constructor>
<param name="configurationName" parameterType="System.String">
<value value="CustomerAccountService" />
</param>
</constructor>
</typeConfig>
</type>
<!-- customer account channel factory -->
<type name="customerChannelFactory"
type="System.ServiceModel.Channels.IChannelFactory`1[[ServiceContracts.Customer.ICustomerAccountProvider, ServiceContracts.Customer]], System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
mapTo="System.ServiceModel.ChannelFactory`1[[ServiceContracts.Customer.ICustomerAccountProvider, ServiceContracts.Customer]], System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<typeConfig extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement, Microsoft.Practices.Unity.Configuration">
<constructor>
<param name="binding" parameterType="System.ServiceModel.Channels.Binding, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<dependency name="customerBinding" />
</param>
</constructor>
</typeConfig>
</type>
The error i get is that it cannot construct the type because it is an interface, even though the mapping to a concrete type is clearly there. Notice i am trying to constrict the type resolution to specific types so it only works with IChannelFactory<ISomeType>
and not IChannelFactory<ISomeOtherType>
, for instance. perhaps this isn't ythe correct way to do things?
If i just try to resolve the Binding
in isolation it says it cannot disambiguate from other constructors taking one parameter (even though i defined the param type to be string!)
Any ideas or pointers what i am doing wrong here peeps? Or perhaps even a solution ;-)
Thanks