我有一个wcf服务。宿主是这么写的,前面是连接oracle数据库 string ConnectionString = "Data Source=SDETEST;user=sde;password=sde;Pooling=true;Min Pool Size=4;Max Pool Size=1000";
OracleConnection conn = new OracleConnection(ConnectionString);
conn.Open();
RestServiceImpl rest = new RestServiceImpl(conn);
WebServiceHost host = new WebServiceHost(rest);
host.Open();
Console.WriteLine("Service is running");
Console.ReadLine();
host.Close();;之前服务里这样用[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single, IncludeExceptionDetailInFaults = true)]
客户端调用没问题。可是我要让数据库能够并发访问,先是将oncurrencyMode = ConcurrencyMode.Single改为Multiple,可是本身service并发明显不行。于是就将InstanceContextMode = InstanceContextMode.Single改为percall,可是改了以后host.open()提示出错了,错误内容是:
“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.”
请教各位怎么改才行。。或者给我个新思路,最终目的是用rest能并发访问数据库。
OracleConnection conn = new OracleConnection(ConnectionString);
conn.Open();
RestServiceImpl rest = new RestServiceImpl(conn);
WebServiceHost host = new WebServiceHost(rest);
host.Open();
Console.WriteLine("Service is running");
Console.ReadLine();
host.Close();;之前服务里这样用[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single, IncludeExceptionDetailInFaults = true)]
客户端调用没问题。可是我要让数据库能够并发访问,先是将oncurrencyMode = ConcurrencyMode.Single改为Multiple,可是本身service并发明显不行。于是就将InstanceContextMode = InstanceContextMode.Single改为percall,可是改了以后host.open()提示出错了,错误内容是:
“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.”
请教各位怎么改才行。。或者给我个新思路,最终目的是用rest能并发访问数据库。
解决方案 »
- 请问各位C#代码里面怎么做oracle数据库备份和还原
- 问一个日期转换问题:小弟网上下了WdatePicker.js,来点击textbox得到日期
- C#如何计算两个日期d1和d2相差的天数x
- 关于pictureBox的问题
- 外部程序怎么调用静态的类实例?
- 刷新系统环境变量问题
- DataSet 怎么导出成excel格式
- 如何判断一字符串("0.123",".123","123,456,789.0","-.123","+0.123",“1.46285150E-07”或“1.46026710E+07”等)是否为有效数值????
- 弱智的问题,来拿分亚!!!
- C#中类Convert没有ToFloat方法怎么办???
- 把数据库中的表复制到另一个数据中出现了错误
- 求個读取文本文档,读出来后再写入sql數據庫的代碼.
你开启数据库为什么要放在Host不放在WCF里呢?
using (ServiceHost host = new ServiceHost(typeof(CaptureWCFService)))
{
host.Open();
}