Solved

What is the best way to make an inproc COM server out of proc?

Posted on 2004-10-06
10
647 Views
Last Modified: 2013-12-03
I have the inproc COM object that I do not have the source for. I want to make it an out of proc so I can share one instance between all processes. I want to do this the most efficient way possible from a performance standpoint. The inproc COM object can be assumed thread and process safe for simplicity.

I could of course simply wrap* the COM object with my own out of proc server but is there a better solution? Just for example aggregation or something (I don't know much about COM aggregation so it may not even apply).


*Just as a note a fellow developer was telling me that inproc COM calls have a small amount of performace overhead. I'm not sure if I totally believe that but if it is the case, perhaps wrapping the inproc object will do just fine.

0
Comment
Question by:code_snake
  • 4
  • 4
10 Comments
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 12241900
Inproc COM calls (DLL style) have a much smaller perfromance overhead than out of proc (EXE style), if that is what you mean.  

Windows has a built-in inproc COM surrogate host to make in-proc into out-of-proc calls, called DLLHost.exe, which is used primarily when you have a distributed DLL style COM object.  The host computer needs a process to load the DLL, so DLLHost is used.  You could probably configure your in-proc COM object to "look like" a remote COM object by fiddling with dcomcnfg and the registry, but that might be more complicated than writing your own wrapper.
0
 

Author Comment

by:code_snake
ID: 12242627
Well since I did not make the statement "inproc COM calls have a small amount of performace overhead" I am not totally sure what was meant by it or what it is relative to. I was looking at it as relative to no COM interface, such as direct DLL method invocation.

I'll have to look in to this DLLHost COM surrogate. Will it work for just any COM object, or does the COM object have to be written specially? Are there other types of COM "surrogates?"

Thanks.
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 12247633
I believe DLLHost will work for any COM object that obeys COM standards (string types and what not), but I'm not sure if it will work as a local host for a local object because it was designed to be a host on a separate machine.  Essentially on the client, when the COM object is registered, it is registered with DLLHost.exe as the executable name.  If you have the actual COM object already registered with the .DLL name, it might mess things up.  It might work if you explicitly ask for a remote object, e.g. in VB you do 'CreateObject  "MyProject.MyClass", "MachineName"' to create a remote object.  I don't know what would happen if you use the local machine for MachineName, it might just use the in-proc version.  I don't know of any others except what you write yourself.  Out-of-proc COM objects can add a lot of overhead if there are a lot of public properties that have to be marshalled between processes.
0
 

Author Comment

by:code_snake
ID: 12248291
I looked into it and that's actually not how it works.  It works fine for LocalServer. The COM object is registered just as normal but there is an added DllSurrogate value under the AppID key. It's that simple.

I've gotten it to work but not how I would like. The COM server does start in the surrogate but a new server is started for every object. I want one shared object.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 16

Expert Comment

by:JohnBPrice
ID: 12248962
Cool, how did you register it so as to get the DllSurrogate?
0
 

Author Comment

by:code_snake
ID: 12249794
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 12249948
Neat, much easier than I expected.  Did you see this paragraph?

"It is best to configure a DLL server that is designed to run alone in its own surrogate process and to service multiple clients across a network with a RunAs value specified under the AppID registry key. Whether the RunAs specifies "Interactive User" or a specific user identity depends upon the user interface, security, and other server requirements. When a RunAs value is specified, only one instance of the server is loaded to service all of the clients, regardless of the identity of the client. On the other hand, do not configure the server with RunAs if the intention is to have one instance of the DLL server running in surrogate to service each remote client identity."
0
 

Author Comment

by:code_snake
ID: 12251268
Yeah, I will have to try that later. I am running in to another issue now.

With the DLL Surrogate the COM server is not forced to run out of process, it just has the ability to do so through the surrogate. If a consumer creates an object still using the CLSCTX_INPROC_SERVER flag, the server is still created in proc. This is apparently how Internet Explorer crates objects. Strangely last night I could have swore that IE started mine out of process. I don't know, it was late and I was probably hallucinating.

So now the task is how to force COM consumers to create the COM object as CLSCTX_LOCAL_SERVER
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12502458
PAQed, with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now