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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:18:38+00:00 2026-05-16T23:18:38+00:00

We have many classes published in a remoting channel as singlecalls. The application resides

  • 0

We have many classes published in a remoting channel as singlecalls. The application resides into a windows service. They are being used in the following scenarios:

  1. From the same application domain
  2. From another application domain using CrossAppDomain remoting channel
  3. From a remote client through the network using a tcp channel

As some of these classes are used in the three cases we have some common code to do operations with them, something like:

using(IRemoteObject remoteObject= (IRemoteObject) 
        RemotingHelper.GetObject(typeof(IRemoteObject)))
{
   remoteObject.DoStuff();
}

The RemotingHelper already knows how to create the objects depending on the scenario. It is a modification of the Ingo Rammer’s one.

All the remote object interfaces inherit from IDisposable, and all remote objects inherit from MarshalByRefObject.

So, in the case of using this code in the first two cases, the code behaves correctly, but when used through real remoting the remote object is created twice and disposed twice.

This happens because the Dispose() call, the one being made by the using statement, is managed as a new remote call, but the remoting infraestructure already called to the dispose of the object automatically, because that’s how it behaves for SingleCall objects: each call creates a new instance and disposes it automatically.

Is there any configuration value to avoid these repeated (redundant) calls?


Edit: I already knew why this happened. In the case of a remote SingleCall IDisposable object the remoting channel automatically calls to Dispose after the Method returns, the second call is done by the proxy generated at client side, causing a instantiation of a new object at server side, just for calling the Dispose method.

This second call is the one I want to avoid because it is unneeded.

  • 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-16T23:18:39+00:00Added an answer on May 16, 2026 at 11:18 pm

    Thinking more about this, I’m inclined to think that this is correct behavior. As I understand SingleCall, each time you call a method on the object, the server creates a new object. So it makes sense that multiple objects are created and disposed. That is, this code:

    IRemoteObject remoteObject= (IRemoteObject) 
            RemotingHelper.GetObject(typeof(IRemoteObject));
    

    Creates a proxy for the object on the client. If I recall correctly, no contact is made with the server.

    Now, when you execute:

    remoteObject.DoStuff();

    A remote call is made. The server creates an object, executes the method, returns values (if any), and disposes of the object.

    Then, when your call Dispose (or the code generated by the using statement does), the server does it again: create an object, calls the Dispose method, and destroys the object.

    This is the way SingleCall works: “When you configure an object to be a SingleCall object, the system creates a new object for each client method invocation.” http://msdn.microsoft.com/en-us/library/aa719487(v=VS.71).aspx

    Why that doesn’t happen in your scenarios 1 and 2 is a bit confusing, though.

    OLD RESPONSE:

    I don’t know of any configuration parameter to prevent that behavior. However, if you implemented the Dispose method as recommended, you should have a flag that says whether the object has already been disposed. So calling Dispose multiple times shouldn’t be an issue.

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

Sidebar

Related Questions

Many classes in Cocoa/Cocoa Touch have the NS prefix. What does it mean?
I have many small files containing code fragments, pseudo-code algorithms, classes, templates, SQL-samples, etc.,
I have seen many apps that take instrument classes and take -javaagent as a
In my project I have a class that is inherited by many other classes.
I have the following 3 classes Book Product SpecialOptions There are many Books, and
I have a few model classes with basic one-to-many relationships. For example, a book
I have many emails coming in from different sources. they all have attachments, many
I know that it's possible to have many classes in a namespace. Now, is
I'm working on a large project (for me) which will have many classes and
Say I have an event defined in an interface. I then have many classes

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.