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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:04:56+00:00 2026-05-19T13:04:56+00:00

I have an out-of-process COM server that needs to keep an eye on things.

  • 0

I have an out-of-process COM server that needs to keep an eye on things. This server runs as a service and is, internally, a singleton. For simplicity sake, I will call him BossCom.

I have another out-of-process COM server that is a worker. It is, for system stability, a single-use server (meaning that if you create 2 WorkerCom’s, there are 2 WorkerCom.exe’s running). For simplicity sake, I will call him WorkerCom.

WorkerCom can be started by anything, even by itself if someone runs him via the command line with the right command line arguments.

The overall goal is for BossCom to know what WorkerComs are around, know what they are doing, and be able to give them orders (pause, stop, ramp up, etc).

My initial thought at this would be that whenever WorkerCom starts, he would CoCreateInstance a BossCom and call BossCom->RegisterWorker(IUnknown me). Then when the WorkerCom is about to shutdown, he would call BossCom->UnregisterWorker(IUnknown me). BossCom could QueryInterface the IUnknown for IWorkerCom and be able to issue commands.

That would work great if all these com objects were in the same process, but they’re not. I thought about using the GlobalInterfaceTable, but it is only global in the sense of a single process.

I have spent a few days researching this and am at a loss. Maybe I’m tunnel-visioned.

How can I marshal a reference to a com object from the Worker to the Boss?

Oh, and, for what it’s worth, BossCom is written in C# and WorkerCom is written in ATL C++ but I’ll take solutions written in VB, Scala, Lisp, or anything. I figure I can translate the core idea. 🙂

  • 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-19T13:04:57+00:00Added an answer on May 19, 2026 at 1:04 pm

    As per the comments, this does indeed work out of the box. There is one additional detail though that makes it work.

    Originally when I was looking at C# interfaces that dealt with copying interfaces, the argument type was IntPtr. Well, an IntPtr is just a long so it transfers the value as is and, as such, doesn’t work.

    The key is to set the MarshalAs attribute on the argument. So my RegisterWorker method looks like this:

        public void RegisterWorker(
            [In, MarshalAs(UnmanagedType.IUnknown)] object ptr
            )
        {
            IWorkerCom worker = (IWorkerCom) ptr;
            Workers.Add(worker);
        }
    

    Utterly amazing.

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

Sidebar

Related Questions

When you have a piece of software that runs an out of process COM
I need to create an out-of-process COM server (.exe) in C# that will be
I have an out-of-process COM server written in C++, which is called by some
I have an Out-of-process COM server executable which was developed using Visual Studio 6.0
In a simple windows setup we have a COM singleton that runs as an
I have a console app that performs a lengthy process. I am printing out
It is about Window COM component. Server.exe: an 32bit out-of-process COM server CLSID_Application: The
I have read about storing session state out-of-process but still in memory by configuring
I'm trying to figure out how XSLT process namespace prefixes and have following example:
I have found out that I am doing WPF wrong and frustratingly must overhaul

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.