【发布时间】:2015-01-02 22:51:03
【问题描述】:
我有一个自托管的 WCF 服务,我使用 Castle Windsor 作为 DI 容器。我遇到了这个异常:
System.TypeLoadException occurred
_HResult=-2146233054
_message=GenericArguments[0], 'System.ServiceModel.ServiceHostBase', on
'Castle.Facilities.WcfIntegration.IChannelFactoryBuilder`1[M]'
violates the constraint of type parameter 'M'.
HResult=-2146233054
IsTransient=false
Message=GenericArguments[0], 'System.ServiceModel.ServiceHostBase', on
'Castle.Facilities.WcfIntegration.IChannelFactoryBuilder`1[M]'
violates the constraint of type parameter 'M'.
ResourceId=0
TypeName=""
InnerException:
Castle 容器的配置如下:
Container = new WindsorContainer()
.AddFacility<WcfFacility>();
Container.Register(
Component.For<IReportsService>().ImplementedBy<ReportsService>().LifestylePerWcfOperation(),
Component.For<IAdminServices>().ImplementedBy<AdminServices>().LifestylePerWcfOperation(), etc...
我通过这段代码创建 WCF 服务:
host = new DefaultServiceHostFactory().CreateServiceHost(typeof(IAdminServices).AssemblyQualifiedName, new Uri[0]);
host.Open();
它工作正常,但如果我在调试中运行选中“抛出异常时中断”选项,调试器总是在线停止
host = new DefaultServiceHostFactory().CreateServiceHost(typeof(IAdminServices).AssemblyQualifiedName, new Uri[0]);
我向我展示了上面列出的异常。
我是否以错误的方式将 Castle 与 WCF 一起使用?我可以避免这个异常吗?
编辑:
这个问题只出现在Visual Studio 2013,在2012就可以了。
我使用这些版本的 Castle:
城堡核心 - 3.3.0
城堡 WcfIntegrationFacility - 3.3.0
温莎城堡 - 3.3.0
【问题讨论】:
标签: .net wcf castle-windsor castle wcffacility