Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 152257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:35:27+00:00 2026-05-11T09:35:27+00:00

I have an abstract class which I would like to be able to expose

  • 0

I have an abstract class which I would like to be able to expose to WCF so that any subclasses will also be able to be started as a WCF service.
This is what I have so far:

[ServiceContract(Name = 'PeopleManager', Namespace = 'http://localhost:8001/People')] [ServiceBehavior(IncludeExceptionDetailInFaults = true)] [DataContract(Namespace='http://localhost:8001/People')] [KnownType(typeof(Child))] public abstract class Parent {     [OperationContract]     [WebInvoke(Method = 'PUT', UriTemplate = '{name}/{description}')]     public abstract int CreatePerson(string name, string description);      [OperationContract]     [WebGet(UriTemplate = 'Person/{id}')]     public abstract Person GetPerson(int id); }  public class Child : Parent {     public int CreatePerson(string name, string description){...}     public Person GetPerson(int id){...} } 

When trying to create the service in my code I use this method:

public static void RunService() {     Type t = typeof(Parent); //or typeof(Child)     ServiceHost svcHost = new ServiceHost(t, new Uri('http://localhost:8001/People'));     svcHost.AddServiceEndpoint(t, new BasicHttpBinding(), 'Basic');     svcHost.Open(); } 

When using Parent as the type of service I get
The contract name 'Parent' could not be found in the list of contracts implemented by the service 'Parent'. OR Service implementation type is an interface or abstract class and no implementation object was provided.

and when using the Child as the type of service I get
The service class of type Namespace.Child both defines a ServiceContract and inherits a ServiceContract from type Namespace.Parent. Contract inheritance can only be used among interface types. If a class is marked with ServiceContractAttribute, then another service class cannot derive from it.

Is there a way to expose the functions in the Child class so I don’t have to specifically add the WCF attributes?

Edit
So this

[ServiceContract(Name= 'WCF_Mate', Namespace='http://localhost:8001/People')]       public interface IWcfClass{}        public abstract class Parent : IWcfClass {...}       public class Child : Parent, IWcfClass {...} 

with starting the service with Child returns
The contract type Namespace.Child is not attributed with ServiceContractAttribute. In order to define a valid contract, the specified type (either contract interface or service class) must be attributed with ServiceContractAttribute.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:35:28+00:00Added an answer on May 11, 2026 at 9:35 am

    The service contract is usually an interface, not a class. Place your contract into an interface, have the abstract class implement this interface, and let us know what happens when you use Child to start the service.

    Edit: Ok, now you need to modify your RunService method to this below. The contract type if IWcfClass, not Child or Parent.

    public static void RunService() {         Type t = typeof(Child);         ServiceHost svcHost = new ServiceHost(t, new Uri('http://localhost:8001/People'));         svcHost.AddServiceEndpoint(typeof(IWcfClass), new BasicHttpBinding(), 'Basic');         svcHost.Open(); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 234k
  • Answers 234k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer From the standard, copy-initialization for class types where the cv-unqualified… May 13, 2026 at 5:56 am
  • Editorial Team
    Editorial Team added an answer The only possible benefit I can think of is your… May 13, 2026 at 5:56 am
  • Editorial Team
    Editorial Team added an answer It will not block if it's already read at least… May 13, 2026 at 5:56 am

Related Questions

Picture the following situation. I have an XML document as follows, <Form> <Control Type=Text
Resolution: No I'm no longer extending the original parent. Original: Is there a way
I have an abstract user control(baseModule) that has a property that I plan on
I have a class that I want to use to store properties for another

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.