© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
9 replies
PizzaWizard

Understanding COM interface references for an ASP.NET REST API...

Hi all, I'm new-ish to Windows, so forgive me but my knowledge of COM is pretty amateur. I'm running a simulation application on a backend server that implements the COM interface IDispatch to create an interface called IRemoteControl like so:

interface IRemoteControl : IDispatch
{
     HRESULT NewModel();
     HRESULT LoadModel(BSTR);
     HRESULT SaveModel(BSTR);
     HRESULT CloseModel();
     HRESULT StartSimulation(BSTR);
     HRESULT StopSimulation();
     HRESULT ResetSimulation(BSTR);
     HRESULT GetValue(BSTR,[out,retval]VARIANT*);
     HRESULT SetValue(BSTR,VARIANT);
     HRESULT Quit();
};
interface IRemoteControl : IDispatch
{
     HRESULT NewModel();
     HRESULT LoadModel(BSTR);
     HRESULT SaveModel(BSTR);
     HRESULT CloseModel();
     HRESULT StartSimulation(BSTR);
     HRESULT StopSimulation();
     HRESULT ResetSimulation(BSTR);
     HRESULT GetValue(BSTR,[out,retval]VARIANT*);
     HRESULT SetValue(BSTR,VARIANT);
     HRESULT Quit();
};


We have a single host machine and expect 4-6 users at a time to be sending messages over an API to start, stop, and reset simulations all running on separate instances of this application on the backend server.

I can start the program and manipulate it quite easily in ASP.NET. I import the application's included Type Library DLL as a project dependency, then I can do something like
        [HttpPost("remote-control/create")]
        public IActionResult CreateRemoteControl(string? updatedPath)
        {
RemoteControl remoteControl = new();
return OK();
// Handle other cases, etc.
        }
        [HttpPost("remote-control/create")]
        public IActionResult CreateRemoteControl(string? updatedPath)
        {
RemoteControl remoteControl = new();
return OK();
// Handle other cases, etc.
        }

Whenever I send subsequent calls over a different route to do something like start/stop/reset the simulation, I'm able to do so on the most recently-spawned application instance.

However, when multiple users are connected to this server at the same time, I want to be able to assign each user a specific instance of this application, so that subsequent calls only affect that user's instance (so that a user can't send a "reset" message that resets the most recently spawned process, even if it was spawned by another user).

I can find the process ID of a spawned RemoteControl object using
string currentProcessID = remoteControl.GetCurrentProcessId().ToString();
string currentProcessID = remoteControl.GetCurrentProcessId().ToString();
, but I don't know how to use that to restrict commands to specific COM interfaces.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

❔ Deploying an asp.net rest API into azure or aws or gc
C#CC# / help
3y ago
❔ CRUD API ASP.Net
C#CC# / help
3y ago
✅ SEO for an asp.net blog?
C#CC# / help
8mo ago