Pregunta

I am creating a net.tcp based WCF service to control one of our backend applications. During development and testing on a Windows machine everything worked as expected. However when I tried to run the very same application using Mono on either the same Windows box (Mono 2.10.6) or on Debian Squeeze (with Mono 2.10.5), I suddenly get a TypeLoadException in the ChannelFactory.

In the end it comes down to just this call that fails:

controlHost = ChannelFactory<IControlServiceContract>.CreateChannel(
    new NetTcpBinding(SecurityMode.None),
    new EndpointAddress(endpointAddress)
);

With this definition for IControlServiceContract in another assembly:

[ServiceContract]
public interface IControlServiceContract
{
    [OperationContract(IsOneWay = true)]
    void Ping ();

    [OperationContract(IsOneWay = true)]
    void Shutdown ();

    [OperationContract]
    int GetCommandCount ();        
}

Which runs fine when started directly (i.e. using .NET).

When executed using mono --debug --runtime=v4.0 though it crashes with this super sweet stack trace:

! Ein Fehler ist beim Erzeugen des Kanals auf net.tcp://localhost:34684/watchdog/watchdog.ctrl/ aufgetreten

   A type load exception has occurred.
  at System.Linq.Enumerable.Union[Object] (IEnumerable`1 first, IEnumerable`1 second, IEqualityComparer`1 comparer) [0x00014] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.10.6\mcs\class\System.Core\System.Linq\Enumerable.cs:2948
  at System.Linq.Enumerable.Union[Object] (IEnumerable`1 first, IEnumerable`1 second) [0x00007] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.10.6\mcs\class\System.Core\System.Linq\Enumerable.cs:2938
  at System.ServiceModel.Description.ContractDescriptionGenerator.GetOrCreateOperation (System.ServiceModel.Description.ContractDescription cd, System.Reflection.MethodInfo mi, System.Reflection.MethodInfo serviceMethod, System.ServiceModel.OperationContractAttribute oca, System.Type asyncReturnType, Boolean isCallback, System.Type givenServiceType) [0x001f2] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.10.6\mcs\class\System.ServiceModel\System.ServiceModel.Description\ContractDescriptionGenerator.cs:314
  at System.ServiceModel.Description.ContractDescriptionGenerator.FillOperationsForInterface (System.ServiceModel.Description.ContractDescription cd, System.Type exactContractType, System.Type givenServiceType, Boolean isCallback) [0x00131] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.10.6\mcs\class\System.ServiceModel\System.ServiceModel.Description\ContractDescriptionGenerator.cs:240
  at System.ServiceModel.Description.ContractDescriptionGenerator.GetContractInternal (System.Type givenContractType, System.Type givenServiceType, System.TypeserviceTypeForCallback) [0x00296] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.10.6\mcs\class\System.ServiceModel\System.ServiceModel.Description\ContractDescriptionGenerator.cs:197
  at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type givenContractType, System.Type givenServiceType, System.Type serviceTypeForCallback) [0x00000] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.10.6\mcs\class\System.ServiceModel\System.ServiceModel.Description\ContractDescriptionGenerator.cs:136
  at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type givenContractType, System.Type givenServiceType) [0x00000] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.10.6\mcs\class\System.ServiceModel\System.ServiceModel.Description\ContractDescriptionGenerator.cs:131
  at System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type contractType) [0x00000] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.10.6\mcs\class\System.ServiceModel\System.ServiceModel.Description\ContractDescriptionGenerator.cs:101
  at System.ServiceModel.Description.ContractDescription.GetContract (System.Type contractType) [0x00017] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.10.6\mcs\class\System.ServiceModel\System.ServiceModel.Description\ContractDescription.cs:66
  at System.ServiceModel.ChannelFactory`1[com.derixx.dll.controlservicehost.ServiceBase.IControlServiceContract].CreateDescription () [0x00000] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.10.6\mcs\class\System.ServiceModel\System.ServiceModel\ChannelFactory_1.cs:185
  at System.ServiceModel.ChannelFactory`1[com.derixx.dll.controlservicehost.ServiceBase.IControlServiceContract]..ctor (System.Type type) [0x00033] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.10.6\mcs\class\System.ServiceModel\System.ServiceModel\ChannelFactory_1.cs:56
  at System.ServiceModel.ChannelFactory`1[com.derixx.dll.controlservicehost.ServiceBase.IControlServiceContract]..ctor (System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in <filename unknown>:0
  at System.ServiceModel.ChannelFactory`1[com.derixx.dll.controlservicehost.ServiceBase.IControlServiceContract].CreateChannel (System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress address) [0x00000] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.10.6\mcs\class\System.ServiceModel\System.ServiceModel\ChannelFactory_1.cs:130
  at applicationframework.ControlApplicationBase.ConnectionCreate (IControlServiceContract& controlHost, System.String endpointHost, Int32 endpointPort, System.String endpointPath) [0x00000] in <filename unknown>:0

All assemblies used int his project are either our own ones targeted at Framework 4.0, core assemblies and log4net 1.2.10/2.0.50727.

Does anyone have a clue what this could be and where I should start digging?

¿Fue útil?

Solución

Well, if it works on .NET and not Mono it's definitely a bug.

I would go ahead and first thing submit it in http://bugzilla.xamarin.com/

Then maybe hangout in irc://irc.gnome.org/mono , and poke Atsushi Enomoto (nick "eno") which is the maintainer of WCF, to see what he thinks.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top