我尝试在带有 mono 3.2.8 的 ubuntu 服务器上运行 Nancy,当我启动服务器时,它给出了以下错误:
:~/temp$ sudo mono Medusa.WEB.Server.exe
System.InvalidOperationException: ContractDescription 'NancyWcfGenericService' has zero operations; a contract must have at least one operation.
at System.ServiceModel.Description.ServiceEndpoint.Validate () [0x00000] in <filename unknown>:0
at System.ServiceModel.ServiceHostBase.ValidateDescription () [0x00000] in <filename unknown>:0
at System.ServiceModel.ServiceHostBase.InitializeRuntime () [0x00000] in <filename unknown>:0
at System.ServiceModel.ServiceHostBase.OnOpen (TimeSpan timeout) [0x00000] in <filename unknown>:0
at System.ServiceModel.Channels.CommunicationObject.Open (TimeSpan timeout) [0x00000] in <filename unknown>:0
at System.ServiceModel.Channels.CommunicationObject.Open () [0x00000] in <filename unknown>:0
at Medusa.WEB.Server.WcfWebServer.Start () [0x00000] in <filename unknown>:0
当我尝试使用 mono 2.10 时,这个错误没有发生,相反,当我调用其余的 Web 服务时,我遇到了不同的错误(这就是我更新到 3.2.8 的原因)。此外,该服务器可以在 Windows 上运行。
最佳答案
WCF 并没有真正在 Mono 上实现或支持,说实话,我很惊讶它能走到这一步。
如果您想在 Mono 上自行托管,请使用 Nancy.Hosting.Self 或 Nancy.Owin 以及 OWIN 自托管(例如 Katana 或 nowin)。
关于c# - 使用 NancyWcfGenericService 运行 Nancy + Mono 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23807678/