如何使用Mono创建WCF服务?

时间:2010-07-18 01:46:07

标签: wcf mono

我在Windows上运行了WCF。我想在运行SUSE和Mono的开发服务器上部署它 - 或者至少测试它。

在GimpNet的IRC频道#monodev上询问Mono中的WCF示例后,我从subversion中的olive模块下载了这些示例。

没有任何示例实际使用Web.config文件来创建服务总线,而是从ServiceHost继承并手动创建绑定等。现在我想知道, Mono是否使用Web.config文件,还是应该手动创建绑定

现在,在MonoDevelop上运行我的服务并点击http://localhost:8080/(或http://localhost:8080/ServiceName.svc - 似乎并不重要)会给我一个我无法识别的错误:

Server Error in '/' Application

Value must be positive integer.

Description: HTTP 500. Error processing request.

Stack Trace:

System.ArgumentException: Value must be positive integer.
  at System.Xml.XmlDictionaryReaderQuotas.Check (Int32 value) [0x0002a] in /usr/src/packages/BUILD/mono-2.6.4/mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryReaderQuotas.cs:94 
  at System.Xml.XmlDictionaryReaderQuotas.set_MaxBytesPerRead (Int32 value) [0x00000] in /usr/src/packages/BUILD/mono-2.6.4/mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryReaderQuotas.cs:69 
  at System.ServiceModel.Configuration.BasicHttpBindingElement.OnApplyConfiguration (System.ServiceModel.Channels.Binding binding) [0x00043] in /usr/src/packages/BUILD/mono-2.6.4/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BasicHttpBindingElement.cs:214 
  at System.ServiceModel.Configuration.StandardBindingElement.ApplyConfiguration (System.ServiceModel.Channels.Binding binding) [0x00030] in /usr/src/packages/BUILD/mono-2.6.4/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingElement.cs:139 
  at System.ServiceModel.Configuration.ConfigUtil.CreateBinding (System.String binding, System.String bindingConfiguration) [0x00063] in /usr/src/packages/BUILD/mono-2.6.4/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ConfigUtil.cs:81 
  at System.ServiceModel.ServiceHostBase.ApplyConfiguration () [0x00110] in /usr/src/packages/BUILD/mono-2.6.4/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs:320 
  at System.ServiceModel.ServiceHostBase.InitializeDescription (System.ServiceModel.UriSchemeKeyedCollection baseAddresses) [0x0001c] in /usr/src/packages/BUILD/mono-2.6.4/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs:368 
  at System.ServiceModel.ServiceHost.InitializeDescription (System.Type serviceType, System.ServiceModel.UriSchemeKeyedCollection baseAddresses) [0x0001d] in /usr/src/packages/BUILD/mono-2.6.4/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHost.cs:160 
  at System.ServiceModel.ServiceHost..ctor (System.Type serviceType, System.Uri[] baseAddresses) [0x00006] in /usr/src/packages/BUILD/mono-2.6.4/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHost.cs:60 
  at System.ServiceModel.Channels.SvcHttpHandler.EnsureServiceHost () [0x0007d] in /usr/src/packages/BUILD/mono-2.6.4/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs:207 
  at System.ServiceModel.Channels.SvcHttpHandler.ProcessRequest (System.Web.HttpContext context) [0x00000] in /usr/src/packages/BUILD/mono-2.6.4/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs:150 
  at System.Web.HttpApplication+<Pipeline>c__Iterator2.MoveNext () [0x00cdf] in /usr/src/packages/BUILD/mono-2.6.4/mcs/class/System.Web/System.Web/HttpApplication.cs:1362 
  at System.Web.HttpApplication.Tick () [0x00000] in /usr/src/packages/BUILD/mono-2.6.4/mcs/class/System.Web/System.Web/HttpApplication.cs:928 
Version information: Mono Runtime Version: 2.6.4 (tarball Mon Jul 5 13:53:45 UTC 2010); ASP.NET Version: 2.0.50727.1433

有关我该怎么做的任何提示?

2 个答案:

答案 0 :(得分:2)

mono-dev mailing list traffic来看,今年2月/ 3月在Mono上对WCF的web.config支持有一些工作,但尚未发布。您可以尝试building a development version of mono yourself(过时的指南,Mono几天前切换到git),或者只是手动创建biding。后者肯定更容易做到。

答案 1 :(得分:1)

根据异常报告,听起来Mono框架正在选择一个负数(-1?)作为默认值,默认为各种正数。我会在MSDN上查找端点的完整配置,找出Reader Quotas之类的正确默认值,并手动设置它们。如果这解决了问题,我会向Mono团队提交一份错误报告,因为看起来他们在该行的某处有一个错误。