Search code examples
c#mononancy

Error running Nancy + Mono using NancyWcfGenericService


I'm trying to run Nancy at a ubuntu server with mono 3.2.8 and it gives me the following error when I start the server:

:~/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

This error didn't happen when I tryied with mono 2.10, instead I had a different error when I called the rest webservice (that is the reason I updated to 3.2.8). Also, the server works on windows.


Solution

  • WCF isn't really implemented or supported on Mono, I'm quite surprised it gets that far to be honest.

    If you want to self hosted on Mono use Nancy.Hosting.Self, or Nancy.Owin along with an OWIN self host like Katana or nowin.