System.InvalidOperationException: Operation ‘GetServicesAsync’ contains a message with parameters

I am having an issue trying to implement the ONVIF protocol using a modified version of the GitHub project ‘onvif-interface’, as a console application.

In Windows (from command line) the application seems to work fine.

Trying to run in the intended environment (mono on debian), I get the following error.

Unhandled Exception: System.InvalidOperationException: Operation 'GetServicesAsync' contains a message with parameters. Strongly-typed or untyped message can be paired only with strongly-typed, untyped or void message. at System.ServiceModel.Dispatcher.OperationFormatter.Validate (System.ServiceModel.Description.OperationDescription od, System.Boolean isRpc, System.Boolean isEncoded) [0x0006a] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.Dispatcher.OperationFormatter..ctor (System.ServiceModel.Description.OperationDescription od, System.Boolean isRpc, System.Boolean isEncoded) [0x00006] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.Description.ContractDescription.PopulateClientOperation (System.ServiceModel.Dispatcher.ClientRuntime proxy, System.ServiceModel.Description.OperationDescription od, System.Boolean isCallback) [0x001e0] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.Description.ContractDescription.FillClientOperations (System.ServiceModel.Dispatcher.ClientRuntime proxy, System.Boolean isCallback) [0x00055] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.Description.ContractDescription.CreateClientRuntime (System.Object callbackDispatchRuntime) [0x0002d] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.Description.ServiceEndpoint.CreateClientRuntime (System.Object callbackDispatchRuntime) [0x00008] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.MonoInternal.ClientRuntimeChannel..ctor (System.ServiceModel.Description.ServiceEndpoint endpoint, System.ServiceModel.ChannelFactory channelFactory, System.ServiceModel.EndpointAddress remoteAddress, System.Uri via) [0x00000] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel (System.ServiceModel.EndpointAddress address, System.Uri via) [0x0005b] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel (System.ServiceModel.EndpointAddress address) [0x00000] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel () [0x00012] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.ClientBase`1[TChannel].CreateChannel () [0x00006] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.ClientBase`1[TChannel].get_InnerChannel () [0x0000b] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.ClientBase`1[TChannel].get_Channel () [0x00000] in <8cdac92fdd4b495ba10570db10926ad4>:0  at OnvifMonitor.OnvifDeviceMgmt.DeviceClient.OnvifMonitor.OnvifDeviceMgmt.Device.GetServices (OnvifMonitor.OnvifDeviceMgmt.GetServicesRequest request) [0x00001] in <158c175a1c2d469fa76b930de60da396>:0  at OnvifMonitor.OnvifDeviceMgmt.DeviceClient.GetServices (System.Boolean IncludeCapability) [0x0000e] in <158c175a1c2d469fa76b930de60da396>:0  at OnvifMonitor.MonitoringThread.GetOnvifInfo (System.String ip, System.Int32 port) [0x000bd] in <158c175a1c2d469fa76b930de60da396>:0  at OnvifMonitor.Program.Main (System.String[] args) [0x0000c] in <158c175a1c2d469fa76b930de60da396>:0   [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Operation 'GetServicesAsync' contains a message with parameters. Strongly-typed or untyped message can be paired only with strongly-typed, untyped or void message. at System.ServiceModel.Dispatcher.OperationFormatter.Validate (System.ServiceModel.Description.OperationDescription od, System.Boolean isRpc, System.Boolean isEncoded) [0x0006a] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.Dispatcher.OperationFormatter..ctor (System.ServiceModel.Description.OperationDescription od, System.Boolean isRpc, System.Boolean isEncoded) [0x00006] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.Description.ContractDescription.PopulateClientOperation (System.ServiceModel.Dispatcher.ClientRuntime proxy, System.ServiceModel.Description.OperationDescription od, System.Boolean isCallback) [0x001e0] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.Description.ContractDescription.FillClientOperations (System.ServiceModel.Dispatcher.ClientRuntime proxy, System.Boolean isCallback) [0x00055] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.Description.ContractDescription.CreateClientRuntime (System.Object callbackDispatchRuntime) [0x0002d] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.Description.ServiceEndpoint.CreateClientRuntime (System.Object callbackDispatchRuntime) [0x00008] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.MonoInternal.ClientRuntimeChannel..ctor (System.ServiceModel.Description.ServiceEndpoint endpoint, System.ServiceModel.ChannelFactory channelFactory, System.ServiceModel.EndpointAddress remoteAddress, System.Uri via) [0x00000] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel (System.ServiceModel.EndpointAddress address, System.Uri via) [0x0005b] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel (System.ServiceModel.EndpointAddress address) [0x00000] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel () [0x00012] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.ClientBase`1[TChannel].CreateChannel () [0x00006] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.ClientBase`1[TChannel].get_InnerChannel () [0x0000b] in <8cdac92fdd4b495ba10570db10926ad4>:0  at System.ServiceModel.ClientBase`1[TChannel].get_Channel () [0x00000] in <8cdac92fdd4b495ba10570db10926ad4>:0  at OnvifMonitor.OnvifDeviceMgmt.DeviceClient.OnvifMonitor.OnvifDeviceMgmt.Device.GetServices (OnvifMonitor.OnvifDeviceMgmt.GetServicesRequest request) [0x00001] in <158c175a1c2d469fa76b930de60da396>:0  at OnvifMonitor.OnvifDeviceMgmt.DeviceClient.GetServices (System.Boolean IncludeCapability) [0x0000e] in <158c175a1c2d469fa76b930de60da396>:0  at OnvifMonitor.MonitoringThread.GetOnvifInfo (System.String ip, System.Int32 port) [0x000bd] in <158c175a1c2d469fa76b930de60da396>:0  at OnvifMonitor.Program.Main (System.String[] args) [0x0000c] in <158c175a1c2d469fa76b930de60da396>:0  

I do not get the same issue on Windows and the application runs fine.

I am not sure what’s causing this error and what I need to do to fix it, whether I’m chasing my tail with a bug in Mono or if there is something silly to do with the code.

Right now I am taking a very basic example and trying to get a list of the services supported by the ONVIF device:

EndpointAddress serviceAddress = new EndpointAddress(string.Format("http://{0}:{1}/onvif/device_service", ip, port));          HttpTransportBindingElement httpBinding = new HttpTransportBindingElement();         httpBinding.AuthenticationScheme = AuthenticationSchemes.Digest;          var messageElement = new TextMessageEncodingBindingElement();         messageElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None);         CustomBinding bind = new CustomBinding(messageElement, httpBinding);          DeviceClient deviceClient = new DeviceClient(bind, serviceAddress);          if (userName != string.Empty)         {             // Handles adding of SOAP Security header containing User Token (user, nonce, pwd digest)             PasswordDigestBehavior behavior = new PasswordDigestBehavior(userName, password);             deviceClient.Endpoint.Behaviors.Add(behavior);         }          Console.WriteLine(deviceClient.State);          string model; string serial; string firmware; string hardware;          // Console.WriteLine(deviceClient.GetDeviceInformation(out model, out firmware, out serial, out hardware));         // Console.WriteLine(serial);         var Devs = deviceClient.GetServices(true);         foreach(Service t in Devs)         {             Console.WriteLine(t.XAddr);         } 

Thanks!