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 configure Qt Creator to compile qupzilla?

c++ qt qt5 qt5.1

Is there any simple way to configure Qt Creator to compile qupzilla in my folder (not in /usr/bin and /usr/lib)?

Check if a string contains a character ignoring case

c# string contains

I have a textbox on GUI which takes an "Mobile Number" as input. I want to validate it to find out if it has some characters, which would mean the number is invalid

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.