[Mono-list] A problem about WCF interoperation between mono and MS .Net

hayate hayatelee at gmail.com
Mon Apr 23 05:23:56 UTC 2012


Hi all,

These days I've been struggling with a problem: a Windows silverlight app
cannot deserialize the data from a WCF service under Mono, which later
leads to my discovery.

When serializing and deserializing some dictionary style data, it seems the
MS .Net implementation does not work well with Mono imp, I made a simple
case to demo this:

Say I have a WCF service like this:
// WCF service contract
[ServiceContract]
public interface IAnswerService
{
  [OperationContract]
  Dictionary<int, List<string>> Ask ();
}

public class AnswerService : IAnswerService
{
  public Dictionary<int, List<string>> Ask ()
  {
          var d = new Dictionary<int, List<string>>() {  {42, new
List<string>(){"universe", "life"}}  };

      return d;
  }
}

public class Test
{
  public static void Main (string [] args)
  {
        var baseAddress = new Uri("http://localhost:8080/Answer.svc");
        var host = new ServiceHost (typeof (AnswerService));
        var binding = new BasicHttpBinding ();
        host.AddServiceEndpoint(typeof(IAnswerService), binding,
baseAddress);
        host.Open ();

        Console.WriteLine ("Type [CR] to stop...");
        Console.ReadLine ();
        host.Close ();
  }
}

Note the data structure is Dictionary<int, List<string>>. Then I made a
console client to read the data. The problem is, if I run the client under
mono, everything is OK, if I run it under MS .Net, nothing is read. If I
change the data structure to things like Dictionary<int, string>,
everything works as expected.

sum it up:
server under Mono <====not work====> client under MS .Net
server under Mono <=====work=====>  client under Mono
server under MS .Net <=====work=====> client under MS .Net
server under MS .Net <=====work=====> client under Mono

only one case does not work.

Any ideas?

Thanks

Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20120423/3780f06f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WCF_test.tar.bz2
Type: application/x-bzip2
Size: 10865 bytes
Desc: not available
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20120423/3780f06f/attachment-0001.bin>


More information about the Mono-list mailing list