Passing Interface in a WCF Service?

I'm experimenting with WCF Services, and have come across a problem with passing Interfaces.

This works:

[ServiceContract]
public interface IHomeService
{
    [OperationContract]
    string GetString();
}

but this doesn't:

[ServiceContract]
public interface IHomeService
{
    [OperationContract]
    IDevice GetInterface();
}

When I try to compile the client it fails on the GetInterface method. I get an Exception saying that it can't convert Object to IDevice.

On the clientside the IHomeService class correctly implements GetString with a string as it's returntype, but the GetInterface has a returntype of object. Why isn't it IDevice?

Answers


You need to tell the WCF serializer which class to use to serialize the interface

[ServiceKnownType(typeof(ConcreteDeviceType)]

Need Your Help

How to control UITabBar

iphone objective-c xcode storyboard uitabbar

I've created UITabBar (items: info, location and description) in the middle of the content and now i want to set custom background image for tab bar, default select first button and get action when...

recursive sql query call

sql oracle recursion

I have the following table which represent streets from corners to corners