WCF/WF - Error in WCF Error “ does not implement interface member “ in Silverli

Asked By Sreenath G V on 16-Mar-11 11:21 PM

Hi,

I have the following code written…

In IServiceIncident.cs

 

[ServiceContract]

    public interface IServiceIncident

    {

      [OperationContract]

      List<clsApplicationsList> mFnGetApplicationsList();

 

      [OperationContract]

      List<clsProgramList> mFnGetProgramsList();

 

    }

 

And have corresponding classes defined correctly as…

 

  [DataContract]

    public class clsApplicationsList

    {

 

     public string _AppName = "";

 

      [DataMember]

      public string Prp_AppName

      {

        get

        {

          return _AppName;

        }

        set

        {

          _AppName = value;

        }

      }

 

 

In IServiceIncident.svc.cs

 

  public class ServiceIncident : IServiceIncident

    {

public List<clsApplicationsList> mFnGetApplicationsList()

      {

        try

        {}

 

  public List<clsProgramList> mFnGetProgramList()

      {

        }

 

__------------------------------------------

Here I am getting error in svc.cs file as “Error     1    ...Web.ServiceIncident' does not implement interface member ‘...Web.IServiceIncident.mFnGetProgramsList()'    ...Web\ServiceIncident.svc.cs   13     18   ...Web”

 

Any suggestion why this is happening…

Please guide.

 

Thanks

Sreenath

 

 

Mihir Soni replied to Sreenath G V on 17-Mar-11 12:00 AM
Hello,

Your interface defines the method as:
IServiceIncident.mFnGetProgramsList

Your class is not implementing that method because you forgot the s:
mFnGetProgramList // This is missing the s after Program
Sahil Kumar replied to Sreenath G V on 17-Mar-11 12:20 AM
Hi,
    If you use interface as your service contract you got implement all methods of it in you service otherwise it will give this error.

If you dont want to do so then make your service contract as abstract class. And work with that.

Please let me know if you have any queries....
Sreenath G V replied to Mihir Soni on 17-Mar-11 12:39 AM
Thanks a lot man. That was my bad...but got solved..:)
Sreenath G V replied to Sreenath G V on 17-Mar-11 12:41 AM
Thanks a lot man. That was my bad...but got solved..:)
Anoop S replied to Sreenath G V on 17-Mar-11 12:59 AM
The reason for error because of the Implement Interface command does not implement all methods of an interface if any other methods that have the same name and parameters exist in another interface that a class implements. This behavior occurs although the methods may have different return data types.
Check whether all the method in the interface are implemented in the class

For example, the Implement Interface command implements the GetEnumerator method of the IDictionary interface. However, the Implement Interface command does not implement the GetEnumerator method of the IEnumerable interface, although the methods have different return data types.

To resolve this behavior, add the following code to your Web server control class file after the code that the Implement Interface command generates:

System.Collections.IEnumerator System.Collections.IEnumerable.mFnGetProgramsList()
{
  return null;
}