【发布时间】:2013-05-30 23:24:10
【问题描述】:
在我的托管应用程序中,我目前的 WCF 服务运行为:
SomeService service = new SomeService(container) //IUnityContainer
ServiceHost serviceHost = new ServiceHost(service, serviceAddress);
有什么收获? SomeService 定义为:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single
这已经不行了,我需要让它InstanceContextMode.PerCall。
当尝试 .Open() 如果将 InstanceContextMode 更改为“PerCall” - 它会抛出:
System.InvalidOperationException: In order to use one of the ServiceHost constructors that takes a service instance, the InstanceContextMode of the service must be set to InstanceContextMode.Single. This can be configured via the ServiceBehaviorAttribute. Otherwise, please consider using the ServiceHost constructors that take a Type argument
这是我的问题的解决方案吗? How do I pass values to the constructor on my wcf service?
我的主要担忧:
我在这个托管应用程序中运行不同类型的服务,看来这个解决方案只有在我运行一种类型的服务时才是好的。
【问题讨论】:
标签: c# wcf servicehost