Silverlight WCF service consuming inherited types in datacontract

Posted by RemotecUk on Stack Overflow See other posts from Stack Overflow or by RemotecUk
Published on 2010-01-24T01:20:13Z Indexed on 2010/04/21 11:33 UTC
Read the original article Hit count: 439

Hi,

Im trying to consume a WCF service in silverlight...

What I have done is to create two seperate assemblies for my datacontracts...

  1. Assembly that contains all of my types marked with data contracts build against .Net 3.5

  2. A Silverlight assembly which links to files in the 1st assembly.

This means my .Net app can reference assembly 1 and my silverlight app assembly 2. This works fine and I can communicate across the service.

The problems occur when I try to transfer inherited classed. I have the following class stucture...

IFlight - an interface for all types of flights.

BaseFlight : IFlight - a baseflight flight implements IFlight

AdhocFlight : BaseFlight, IFlight - an adhoc flight inherits from baseflight and also implements IFlight.

I can successfully transfer base flights across the service. However I really need to be able to transfer objects of IFlight across the interface as I want one operation contract that can transfer many types of flight...

public IFlight GetFlightBooking()
{
    AdhocFlight af = new AdhocFlight();
    return af;
}

... should work I think?

However I get the error:

"The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error."

Any ideas would be appreciated.

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about wcf