473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Select and attach to specific COM EXE instance as COM object

I am working with an application that is compiled as a COM EXE (written in
Delphi 7). I don't know if it's the nature of COM EXE or if it's implemented
in the COM EXE, but when I create a new object based on the COM interface
using C#, it references the first process/instance it finds of this
interface. This is not ideal for me; I would like to create a modal dialog
box that makes the user select which process to "attach" to. Getting a list
of processes isn't a problem, rather it's getting my COM references in the
C# RCW of the COM interface to attach to the preferred COM EXE rather than
the first one it finds.

I asked the developer of the app as to how to "select" which COM instance
you're attaching to, but he said he was busy and hasn't gotten back to me.
However, I tend to believe that this is something that is pretty generic to
COM EXEs, and I was hoping someone out there might know and could give me a
tip on this?

Thanks,
- Jon
Apr 7 '06 #1
9 1898
i don't think that is the case, that sounds like internal code making sure
that there is only one instance. however, without source, i'm just taking a
stab in the dark so you should take that with a large dose of rock salt.

--
Warm Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley 2006
Blog: http://msmvps.com/blogs/Alvin/
-------------------------------------------------------

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:Om**************@TK2MSFTNGP03.phx.gbl...
I am working with an application that is compiled as a COM EXE (written in
Delphi 7). I don't know if it's the nature of COM EXE or if it's implemented in the COM EXE, but when I create a new object based on the COM interface
using C#, it references the first process/instance it finds of this
interface. This is not ideal for me; I would like to create a modal dialog
box that makes the user select which process to "attach" to. Getting a list of processes isn't a problem, rather it's getting my COM references in the
C# RCW of the COM interface to attach to the preferred COM EXE rather than
the first one it finds.

I asked the developer of the app as to how to "select" which COM instance
you're attaching to, but he said he was busy and hasn't gotten back to me.
However, I tend to believe that this is something that is pretty generic to COM EXEs, and I was hoping someone out there might know and could give me a tip on this?

Thanks,
- Jon

Apr 7 '06 #2
You are confusing COM object instances with COM executable instances. They
are different.

Generally speaking, each client will be allocated their own COM object
whenever they call CoCreateInstance(Ex). Usually the same COM executable
will act as host for all those COM object instances. For obvious reasons,
this is usually desirable for efficiency reasons. There are exceptions to
this scenario. For example, if there are two clients running under different
user accounts and the COM Server executable is set up to run as the
launching user, then COM services will start a second executable in order to
establish a separate security boundary.

There is no direct support from COM to do what you are asking for. However,
I suspect there is a clever way of implementing this (with some considerable
research on your part if you haven't done this before) by building a custom
class factory.

To carry this discussion further, I think it would be helpful if you would
explain why there are multiple COM executables, how this was configured and
why. I suspect there may be a cleaner design and a better solution at hand
if you explained more.

Brian
Apr 7 '06 #3
You can bind to a specific instance using the IRunningObjectTable & IMoniker
interfaces, see using System.Runtime.InteropServices.ComTypes; in MSDN
(version 2 of the Framework!).

Willy.

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:Om**************@TK2MSFTNGP03.phx.gbl...
|I am working with an application that is compiled as a COM EXE (written in
| Delphi 7). I don't know if it's the nature of COM EXE or if it's
implemented
| in the COM EXE, but when I create a new object based on the COM interface
| using C#, it references the first process/instance it finds of this
| interface. This is not ideal for me; I would like to create a modal dialog
| box that makes the user select which process to "attach" to. Getting a
list
| of processes isn't a problem, rather it's getting my COM references in the
| C# RCW of the COM interface to attach to the preferred COM EXE rather than
| the first one it finds.
|
| I asked the developer of the app as to how to "select" which COM instance
| you're attaching to, but he said he was busy and hasn't gotten back to me.
| However, I tend to believe that this is something that is pretty generic
to
| COM EXEs, and I was hoping someone out there might know and could give me
a
| tip on this?
|
| Thanks,
| - Jon
|
|
Apr 7 '06 #4
> You are confusing COM object instances with COM executable instances. They
are different.
Not at all; C# sees the COM interface, wrapped in the CLR, as an object. I
think you might be confusing my special use of "COM object" with COM
components or server instances.
There is no direct support from COM to do what you are asking for.
However, I suspect there is a clever way of implementing this (with some
considerable research on your part if you haven't done this before) by
building a custom class factory.
If you're certain that COM doesn't support this without hacks then I will
stop researching this.
To carry this discussion further, I think it would be helpful if you would
explain why there are multiple COM executables, how this was configured
and why. I suspect there may be a cleaner design and a better solution at
hand if you explained more.
It's just a shrink-wrapped business application, compiled as an ActiveX EXE,
that supports Active Scripting and I was extending it with .NET by running
my own .NET process and accessing the EXE's COM interfaces. The application
supports multiple instances though--this is useful because each one can
point to a different database or log in as a different user--but the .NET
process I built can only "see" the first one.

I was also trying to "hook" into its interfaces from the Active Scripting
environment using the COM interfaces, but with multiple processes running,
the second instance's script would be confusing its host's COM interface
with the first process.

- Jon
"Brian Muth" <bm***@mvps.org> wrote in message
news:eZ**************@TK2MSFTNGP03.phx.gbl... You are confusing COM object instances with COM executable instances. They
are different.

Generally speaking, each client will be allocated their own COM object
whenever they call CoCreateInstance(Ex). Usually the same COM executable
will act as host for all those COM object instances. For obvious reasons,
this is usually desirable for efficiency reasons. There are exceptions to
this scenario. For example, if there are two clients running under
different user accounts and the COM Server executable is set up to run as
the launching user, then COM services will start a second executable in
order to establish a separate security boundary.

There is no direct support from COM to do what you are asking for.
However, I suspect there is a clever way of implementing this (with some
considerable research on your part if you haven't done this before) by
building a custom class factory.

To carry this discussion further, I think it would be helpful if you would
explain why there are multiple COM executables, how this was configured
and why. I suspect there may be a cleaner design and a better solution at
hand if you explained more.

Brian

Apr 13 '06 #5
> There is no direct support from COM to do what you are asking for.
However, I suspect there is a clever way of implementing this (with some
considerable research on your part if you haven't done this before) by
building a custom class factory.
If you're certain that COM doesn't support this without hacks then I will
stop researching this.
To carry this discussion further, I think it would be helpful if you would
explain why there are multiple COM executables, how this was configured
and why. I suspect there may be a cleaner design and a better solution at
hand if you explained more.
It's just a shrink-wrapped business application, compiled as an ActiveX EXE,
that supports Active Scripting and I was extending it with .NET by running
my own .NET process and accessing the EXE's COM interfaces. The application
supports multiple instances though--this is useful because each one can
point to a different database or log in as a different user--but the .NET
process I built can only "see" the first one.

I was also trying to "hook" into its interfaces from the Active Scripting
environment using the COM interfaces, but with multiple processes running,
the second instance's script would be confusing its host's COM interface
with the first process.

- Jon
"Brian Muth" <bm***@mvps.org> wrote in message
news:eZ**************@TK2MSFTNGP03.phx.gbl... You are confusing COM object instances with COM executable instances. They
are different.

Generally speaking, each client will be allocated their own COM object
whenever they call CoCreateInstance(Ex). Usually the same COM executable
will act as host for all those COM object instances. For obvious reasons,
this is usually desirable for efficiency reasons. There are exceptions to
this scenario. For example, if there are two clients running under
different user accounts and the COM Server executable is set up to run as
the launching user, then COM services will start a second executable in
order to establish a separate security boundary.

There is no direct support from COM to do what you are asking for.
However, I suspect there is a clever way of implementing this (with some
considerable research on your part if you haven't done this before) by
building a custom class factory.

To carry this discussion further, I think it would be helpful if you would
explain why there are multiple COM executables, how this was configured
and why. I suspect there may be a cleaner design and a better solution at
hand if you explained more.

Brian

Apr 13 '06 #6
> It's just a shrink-wrapped business application, compiled as an ActiveX
EXE, that supports Active Scripting and I was extending it with .NET by
running my own .NET process and accessing the EXE's COM interfaces. The
application supports multiple instances though--this is useful because
each one can point to a different database or log in as a different
user--but the .NET process I built can only "see" the first one.


I'm still confused. Define what you mean by the last phrase: "... the .NET
process can only "see" the first one."

The first what? EXE? or COM instance?

As I said before, you should only have one EXE but that EXE can host
multiple COM instances.

Brian
Apr 13 '06 #7

"Brian Muth" <bm***@mvps.org> wrote in message
news:OX****************@TK2MSFTNGP05.phx.gbl...
It's just a shrink-wrapped business application, compiled as an ActiveX
EXE, that supports Active Scripting and I was extending it with .NET by
running my own .NET process and accessing the EXE's COM interfaces. The
application supports multiple instances though--this is useful because
each one can point to a different database or log in as a different
user--but the .NET process I built can only "see" the first one.
I'm still confused. Define what you mean by the last phrase: "... the .NET
process can only "see" the first one."

The first what? EXE? or COM instance?


Process. (EXE instance.)
As I said before, you should only have one EXE but that EXE can host
multiple COM instances.


As I said before, there already are multiple EXE instances, and third party
EXEs and COM objects must talk to them individually; I'm trying to figure
out how. Come to think of it I think I can implement what I need using
Remoting or Indigo; fortunately, each EXE instance is scriptable.

Jon
Apr 14 '06 #8
Somehow I overlooked this yesterday when I replied to Brian. Thanks Willy!!

Jon
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:OQ**************@TK2MSFTNGP04.phx.gbl...
You can bind to a specific instance using the IRunningObjectTable &
IMoniker
interfaces, see using System.Runtime.InteropServices.ComTypes; in MSDN
(version 2 of the Framework!).

Willy.

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:Om**************@TK2MSFTNGP03.phx.gbl...
|I am working with an application that is compiled as a COM EXE (written
in
| Delphi 7). I don't know if it's the nature of COM EXE or if it's
implemented
| in the COM EXE, but when I create a new object based on the COM
interface
| using C#, it references the first process/instance it finds of this
| interface. This is not ideal for me; I would like to create a modal
dialog
| box that makes the user select which process to "attach" to. Getting a
list
| of processes isn't a problem, rather it's getting my COM references in
the
| C# RCW of the COM interface to attach to the preferred COM EXE rather
than
| the first one it finds.
|
| I asked the developer of the app as to how to "select" which COM
instance
| you're attaching to, but he said he was busy and hasn't gotten back to
me.
| However, I tend to believe that this is something that is pretty generic
to
| COM EXEs, and I was hoping someone out there might know and could give
me
a
| tip on this?
|
| Thanks,
| - Jon
|
|

Apr 14 '06 #9
Willy,

These are interfaces; does the app need to implement these as a starting
point in order to allow for the functionality I seek?

I am not on the dev team that built the app, so that won't work for me. I
suppose I will have to pursue other avenues (remoting, etc), unless you can
assist me further.

Thanks,
Jon
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:OQ**************@TK2MSFTNGP04.phx.gbl...
You can bind to a specific instance using the IRunningObjectTable &
IMoniker
interfaces, see using System.Runtime.InteropServices.ComTypes; in MSDN
(version 2 of the Framework!).

Willy.

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:Om**************@TK2MSFTNGP03.phx.gbl...
|I am working with an application that is compiled as a COM EXE (written
in
| Delphi 7). I don't know if it's the nature of COM EXE or if it's
implemented
| in the COM EXE, but when I create a new object based on the COM
interface
| using C#, it references the first process/instance it finds of this
| interface. This is not ideal for me; I would like to create a modal
dialog
| box that makes the user select which process to "attach" to. Getting a
list
| of processes isn't a problem, rather it's getting my COM references in
the
| C# RCW of the COM interface to attach to the preferred COM EXE rather
than
| the first one it finds.
|
| I asked the developer of the app as to how to "select" which COM
instance
| you're attaching to, but he said he was busy and hasn't gotten back to
me.
| However, I tend to believe that this is something that is pretty generic
to
| COM EXEs, and I was hoping someone out there might know and could give
me
a
| tip on this?
|
| Thanks,
| - Jon
|
|

Apr 14 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: gen_www | last post by:
I am running an applet in Internet Explorer using <Object> tag and trying to attach to it using Netbeans IDE. However Netbeans is not able to attach to the applet. However I can use Netbeans to...
1
by: Covad | last post by:
Hi all, For some reason my change() function is only called when the page loads. I'd much rather it gets called when the select changes. Here's the code: window.onload = init; function...
7
by: MP | last post by:
Hi, I would like to be able to deserialize a stream to a specific instance. Deserialize returns me a new instances and that is not really what we need, we need to deserialized to an existing...
1
by: Darrell Wesley | last post by:
Is there anyway to hook the PrintDialog to the printer icon on the PrintPreviewDialog? I know that you can print a document using the PrintDialog but it does not allow previewing and the...
16
by: Brian D | last post by:
I have a multiple select list that is created dynamically based on a previous selection on an asp page. The first thing I do is to clear the curent option list by ...
0
by: sachinkale123 | last post by:
Hi, I m creating a Setup Project where I m using SQL Server Express and while installing it I m Creating the Instance of Server ex. SachExpress. Now I want to attach my ABC.MDF and ABC.LDF files to...
1
by: Tony Johansson | last post by:
Hello! I use VS 2005. A Datasource can be a Database, Web Service or an Object. So I select Data->Add New Data Source in the menu. In the dialog data Source Configuration Wizard I choose...
6
by: dbuchanan | last post by:
There are three parts to this 1.) How do I cascade menus? 2.) And, how do I cascade menus with a multi-select CheckBoxList?
6
by: GaryDean | last post by:
I see some references on debugging by attaching to a process. There are MSDN articles that show how to attach to a process for debugging. However, I can find no info on how exactly to get the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.