One possibility idea is this: interoperability wise, WCF sucks when there is generic types by adding hash-based suffix on the element names. So, give explicit name on the dictionary object by subclassing it or whatever. If it still doesn't work, I have no idea.

Atsushi Eno

hayate wrote:
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,


_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to