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

  • SEARCH
  • Home
  • 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 980843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:27:08+00:00 2026-05-16T04:27:08+00:00

I have a VERY complex service host which consists of multiple DUPLEX services here.

  • 0

I have a VERY complex service host which consists of multiple DUPLEX services here. They provide a bit of common functionality (Connect, Disconnect, KeepAlive, etc…) but besides that they provide very specific functionality each.

All my services inherit from a common base class (abstract).

So, I’m also responsible for a part of the client application and I want to have the administrative bureaucratic handling of connecting, disconnecting, keep alive pinging and reconnects (etc…) handled in a base class so I can observe the DRY principle AND force other developers to NOT implement their own connection handling.

Is there ANY way to have WCF expose the service base class so I can create a common wrapper class for the bureaucratic waste of time in the client application?

I really don’t want to see each and every developer of future client components create their own wrapper?

And, if you allow the rant:

Why, why, why is Microsoft so totally negligient towards best practices and basic principles of clean code development? It’s the same as with this INotifyPropertyChanged – stuff where one is forced to write masses of unnecessary, repetitive code instead of being provided with a simple attribute for notifying properties…

  • 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. Editorial Team
    Editorial Team
    2026-05-16T04:27:09+00:00Added an answer on May 16, 2026 at 4:27 am

    I don’t know of a good way to make multiple WCF proxies inherit from a common base class. You can manually edit the code that’s generated when you add a service reference, but that’s not good for maintainability.

    But you can have multiple proxies use the same base interface, if you share a contract assembly between the client and the server. You could then write a client-side helper class (maybe using extension methods) to perform common operations on the base interface. You can put the helper class in a shared assembly too, and reuse it from multiple clients.

    I haven’t worked with duplex bindings though, so I’m not sure if that introduces complications.

    For example, suppose you have two services Calculator and Echo, and each needs to implement a Keepalive method. You could define three service contract interfaces:

    [ServiceContract]
    public interface IStatefulService
    { 
        [OperationContract]
        void KeepAlive(int sessionID);
    }
    
    [ServiceContract]
    public interface ICalculator : IStatefulService
    {
        [OperationContract]
        int Add(int a, int b);
    }
    
    [ServiceContract]
    public interface IEcho : IStatefulService
    {
        [OperationContract]
        string Echo(string message);
    }
    

    You can put the service contract interfaces in a common class library that’s shared by both client and server.

    On the server, you’d have your ServiceBase class, which would implement IStatefulService and contain the keepalive-handling code. You’d have a concrete CalculatorService that derives from ServiceBase and implements ICalculator; and a concrete EchoService that derives from ServiceBase and implements IEcho.

    On the client, you’ll need two proxies, one per service. In theory, you can generate the proxies using “add service reference”, using the “reuse types from referenced assemblies” checkbox – but I’ve run into problems with this. Instead, you can just use the ChannelFactory directly, like this:

    var echoer = (new ChannelFactory<IEcho>("")).CreateChannel();
    Console.WriteLine(echoer.Echo("hello"));
    
    var calculator = (new ChannelFactory<ICalculator>("")).CreateChannel();
    Console.WriteLine(calculator.Add(2, 3));
    

    (In production code, you’d want to reuse the channel factories rather than creating them on the fly like this. And you’d dispose of the proxies, and you’d have error handling…)

    You’ll also need to set up the endpoints in the client config file.

    Once you have your two proxies sharing a base interface, you can write a utility class that helps you work with that interface.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a very complex Oracle package here (over 4,100 lines of code) that's
I have a very complex Microsoft Access report. This report is run for multiple
I have an idea for a web-based service. The implementation is very complex. There
I have a very complex controller with a very complex set of views and
I have a very complex web app project I want to re-structure. Naturally, it
I have a rather complex data source for my UITableView. I am very carefully
When creating system services which must have a high reliability, I often end up
Currently I have a service that downloads about 500 records of somewhat complex data,
I have a very basic question however the solution might be somewhat complex. How
We have a very complex config file for JSF managed beans that looks like

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.