473,549 Members | 2,408 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1909
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******** ******@TK2MSFTN GP03.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 CoCreateInstanc e(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 IRunningObjectT able & 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******** ******@TK2MSFTN GP03.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******** ******@TK2MSFTN GP03.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 CoCreateInstanc e(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******** ******@TK2MSFTN GP03.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 CoCreateInstanc e(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******** ********@TK2MSF TNGP05.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******** ******@TK2MSFTN GP04.phx.gbl...
You can bind to a specific instance using the IRunningObjectT able &
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******** ******@TK2MSFTN GP03.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******** ******@TK2MSFTN GP04.phx.gbl...
You can bind to a specific instance using the IRunningObjectT able &
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******** ******@TK2MSFTN GP03.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
1842
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 attach to Weblogic server. a) Have read various documents on various websites including http://java.sun.com/products/plugin/1.3/docs/debugging.html...
1
20684
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 init() {
7
2096
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 instance. Can anyone point me in the rigth direction? Regards -Martin
1
5686
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 PrintPreview dialog does not allow you to select a printer - is there a good and simple way to get around these problems. My users would like to select a...
16
13536
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 document.form1.itemcross.length = 0; The only problem is that it leaves the optgroups. How do I also get rid of the optgroups? Thanks
0
1005
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 that Instance. I know that i can use "sp_attach_db" this command but I m not sure how to Attach 'ABC' database to 'SachExpress' Instance. Please...
1
2401
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 Database. When being asked about Choose Your Data Connection I click New Connection.
6
3485
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
3214
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 debugging to work. I have a wizard page in the anonymous section of my website. If I run it as the startup page in VS it runs fine. But if I link...
0
7542
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7736
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7827
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6066
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5110
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3514
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3494
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1961
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
783
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.