Solved

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

Posted on 2004-10-06
10
654 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

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
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 12248962
Cool, how did you register it so as to get the DllSurrogate?
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

690 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