I have component in which I have dependency to CookieContaier object. I managed to make this work by this code:
ICookieContainerFactory factory = container.Resolve<ICookieContainerFactory>();
container.AddFacility<FactorySupportFacility>()
.Register(Component.For<System.Net.CookieContainer>()
.UsingFactoryMethod(() => factory.GetCookieContainer())
.LifeStyle.Singleton);
But I want to have this things in my configuration file. How should I write this in my config?
I tried this way:
<component id="CookieContainerFactory"
service="ABZ.RFOA.Core.Utility.ICookieContainerFactory, ABZ.RFOA.Core"
type="ABZ.RFOA.Core.Utility.CookieContainerFactory, ABZ.RFOA.Core">
</component>
<component id="CookieContainer"
type="System.Net.CookieContainer, System"
factoryId="CookieContainerFactory"
factoryCreate="GetCookieContainer"
lifestyle="singleton">
</component>
But it's throwing me exception:
Castle.MicroKernel.SubSys开发者_Go百科tems.Conversion.ConverterException : Could not convert from 'System.Net.CookieContainer, System' to System.Type - Maybe type could not be found
I don't understand what System.Type is doing here. How should I solve this?
Try using the assembly qualified name
System.Net.CookieContainer, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
instead of just System.Net.CookieContainer, System
精彩评论