I’m trying to convert a sample I found to an XML config..
If this is what I’d do in code;
IUnityContainer unityContainer = new UnityContainer();
unityContainer.RegisterType<IServiceProxy<ITestService>, ServiceProxy<ITestService, TestServiceClient>>();
What do I do in XML? I’m trying this, but I’m missing something;
<unity>
<typeAliases>
<typeAlias alias="IServiceProxy" type="WCF.IServiceProxy, WCF" />
<typeAlias alias="ITestService"type="Interfaces.ITestService, Interfaces" />
<typeAlias alias="IServiceProxy[ITestService],ServiceProxy[ITestService,TestServiceClient]]" />
</typeAliases>
<containers>
<container name="servicesContainer">
<type type="IServiceProxy" mapTo="ServiceProxy" />
<type type="ITestService" mapTo="TestService" />
</container>
</containers>
</unity>
Your aliases are completely fubared in your example. You can’t use the square bracket syntax in aliases for one, you must use CLR type syntax. In the last alias, you just give an alias which is a big long string but you never specify the type. You also never supply the ServiceProxy alias, so that name just doesn’t exist and can’t be found.
Assuming you’re using Unity 2.0, and you’ve added the appropriate <namespace> and <assembly> nodes in the XML to point to your assemblies, this should work: