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 4087300
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:50:16+00:00 2026-05-20T18:50:16+00:00

Say I have WCF service contract like this [ServiceContract(CallbackContract = typeof(ICallback1), SessionMode = SessionMode.Required)]

  • 0

Say I have WCF service contract like this

[ServiceContract(CallbackContract = typeof(ICallback1),
SessionMode = SessionMode.Required)]
public interface IService1
{
  // some methods
}

The service implementation has InstanceContextMode.Single set for InstanceContextMode
and ICallback1 is something like

public interface ICallback1
{
    [OperationContract]
    void Report(int someValue);
}

Now on client side, I can have a class the implements ICallback1 like

class Callback1 : ICallback1
{
    public void Report(int someValue)
    {
        // alert client
    }
}

and I create client service reference like this

Service1Client serviceClient = new Service1Client(new InstanceContext(new CallBack1())); 

which works fine. Now the problem is that I have some clients that are not interested in the callback so I figured I do not require to implement the callback interface for such clients so I tried this

 Service1Client serviceClient = new Service1Client(null);

and

 Service1Client serviceClient = new Service1Client(new InstanceContext(null));

both reported that the parameter cannot be null. My question is, how can i create a service reference without passing a callback object if the client is not interested in the callback. The only requirement is that all clients should be talking to the same service but otherwise I can restructure the service however. Any thoughts ?

EDIT:

I have also tried SessionMode = SessionMode.Allowed for ServiceContract instead of SessionMode.Required but that didn’t help either.

  • 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-20T18:50:17+00:00Added an answer on May 20, 2026 at 6:50 pm

    Workaround: Remove the CallbackContract from IService1. Create IDuplexService1 which inherits IService1 and contains the CallbackContract. Have Service1Client implement IDuplexService1. When instantiating the host, call ServiceHost.AddServiceEndpoint for both IService1 and IDuplexService1.

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

Sidebar

Related Questions

Let's say I have a WCF contract such as [ServiceContract] public interface IContract {
Let's say I have a WCF service which has a method returning object Person.
I'm trying to use RhinoMock for mocking out a wcf service. Say I have
Lets say have this immutable record type: public class Record { public Record(int x,
Say I have a class named Frog, it looks like: public class Frog {
Let's say that I have specified the following WCF REST Service at the address
I have a WCF service load balanced across three different machines. Let's say these
Lets say I have a WCF service that a client can use to receive
I have a WCF service ( Let's say WCFService1 ) is deployed on two
We are using Dtos in our WCF service interface, but have started to come

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.