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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:53:52+00:00 2026-06-16T01:53:52+00:00

I am working on a project where our server communicate with several servers exposing

  • 0

I am working on a project where our server communicate with several servers exposing the same interface (as in clustering). We use round-robin to select which server to send our request to. So far, we have been using Expression to call our ClusterManager, but this results in some ugly code. It also makes unit tests messy, and a bit difficult to verify method parameters. It also seem to result in some issues with Moq with random exceptions (not topic for this post).

I currently call the server and unit test as documented in the post Moq Setup for interface with action or function arguments

On to the point:

I currently have the following approach:

public interface IServerAdapter 
{
    void CallServer(Expression<Action<IServerExposingToClient>> methodToCall, out bool serverCalled);
}

private void DoSomething()
{
    MainViewModel.ServerAdapter.CallServer(server => server.SaveServerSettings(ServerSettings));
}

I want to change this to be the following:

public interface IServerAdapter 
{
    IServerExposingToClient ServerProxy { get; }
}

private void DoSomething()
{
    MainViewModel.ServerAdapter.ServerProxy.SaveServerSettings(ServerSettings);
}

ServerProxy is a RealProxy, and I need to translate this call to ClusterManager to perform the actual call to the server. Presently, ClusterManager has the same signatures for CallServer, which is a bit redundant for the existing implementation. For the translation of the call in Invoke(IMessage), I have two ideas.

Idea 1
Translate IMethodCallMessage to a lamda expression (which I haven’t been able to figure out how to do) and pass it on to ClusterManager. Except for the issue I have with not knowing how to create the expression, and then again handle the return value. Some methods returns a value, and others don’t, so this involves keeping multiple overloads of ClusterManager.CallServer. I also need to create IMessage to return from Invoke.

Idea 2
Get the RealProxy of the TransparentProxy of the WCF connection I currently use to call the server, and directly call Invoke with the message I have. In my trial (using an integration test), I am seemingly able to call the server successfully, but looking through the ReturnMessage, there is no return value, and the Exception property is set to ArithmetricException when ServiceChannelProxy tries to get message data. This could either be because I did something wrong in my test, or that I can’t use the same LogicalCallContext (or something else) on two separate proxies.

Any pointers on how to deal with this? I prefer Idea 2 as it seems the simplest, and hopefully results in the least amount of code. Implementing all the methods in IServerExposingToClient in a class to call on the correct server is not something I would like to do.

Any pointers on how to deal with this?

  • 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-06-16T01:53:53+00:00Added an answer on June 16, 2026 at 1:53 am

    Using the information found here, I have been able to solve the issue. In the code below, proxy is the ICommunicationObject for the channel to the WCF service. Seems to work quite well.

    public override IMessage Invoke(IMessage msg)
    {
        var methodCall = (IMethodCallMessage)msg;
        var proxy = FindNextProxy();
        try
        {
            MethodBase methodBase = methodCall.MethodBase;
            object[] args = methodCall.Args;
            object returnValue = methodBase.Invoke(proxy, args);
            return CreateReturnMessage(returnValue, methodCall);
        }
        catch (TargetInvocationException ex)
        {
            return CreateReturnMessage(ex.InnerException, methodCall);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our team is currently working on a large project which makes heavy use of
I'm working on a Zend project in a very specific server configuration, our production
I'm currently working on a project where our product at the current version is
Situation: I'm working with Adobe Livecycle ES2 and Flex In our project we show
I'm working on a project and we want to handle our logging using log4j.
I am currently working on a project where one of our goals is to
I'm working on a project where I'm trying to send request to our webservice
A project I'm working on is suffering from some minor performance issues. Our team
Working under linux for our developement, I have an Eclipse Makefile C Project and
I'm working on a SaaS project and mysql is our main database. Our applications

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.