Can you emulate an ActiveX exe in .NET

M

Mike

Hi there,

I'm currently working on converting an ActiveX exe that was written in
VB6 to VB.NET. The original application was written as a TSR which
lives in the system tray providing integration between a web site and
3rd party windows apps (such as MS office, etc...).

I've managed to convert the application to .NET originally using the
upgrade wizard (to get it up to .NET 1.1 and finally up to .NET 2) and
then rewriting a fair bit of the code. However, I'm having a few
difficulties getting the application to run like the old ActiveX exe.
Basically what I want is for this application to:

a.) provide a COM interface
b.) stay resident so that other apps can call it
c.) run as a single instance application (i.e. new apps that call the
program shouldn't start a new instance but should be able to hook into
the running instance).

I've compiled the application as a DLL / assembly and given it a COM
interface, however at present whenever an app tries to talk to the TSR
it starts another instance of it rather then just hooking into the
original instance.

Would anyone have some ideas on how to achieve what I want with VB.NET.


Thanks in advance!
 
C

CMM

VB2005 allows you to easily set your app to be single instance in the
project properties. Not sure if there's some other mechanism to it.

Between .NET apps, the only way to mimic the behavior of ActiveX servers is
to use Remoting (which is not as hard as it first seems) even on the same
machine.
 
M

m.posseth

Well with Remoting you can cross the aplication domain boundary`s

i found this book to be verry helpfull
http://www.amazon.com/gp/product/07...f=pd_bbs_2/002-6114261-2231201?_encoding=UTF8

you can do what you want by creating a singleton component

however

a.) provide a COM interface ' afaik this will start a new instance , so
if you component is running as remoting component and a legacy app connects
through the com interface a new instance is created
b.) stay resident so that other apps can call it override the
InitializeLifetimeService

Public Overrides Function InitializeLifetimeService() As Object

Return Nothing

End Function

c.) run as a single instance application (i.e. new apps that call the
program shouldn't start a new instance but should be able to hook into the
running instance).

this is standard behavior of a remoting singleton


The problem i am facing is that i would like to pass a gui to a win32 app
as you can with a ActiveX exe this doesn`t seem to be possible with .Net
without creating memory leaks etc etc


regards

Michel Posseth [MCP]
 
J

Jim Wooley

Basically what I want is for this application to:
a.) provide a COM interface
b.) stay resident so that other apps can call it
c.) run as a single instance application (i.e. new apps that call the
program shouldn't start a new instance but should be able to hook into
the running instance).

It sounds like you want a single instance winform application or windows
service. I have a write-up of single instance winforms with 1.x and 2.0 at
http://devauthority.com/blogs/jwooley/archive/2005/07/28/318.aspx.

Jim Wooley
 
M

m.posseth

after reading the article


No that is not what he wants with VB6 it is possible to creat a so called
out of process component ( Activex executable ) when this one process is
running
multiple clients can connect to this one sole instance .

In VB.Net this is only possible with Remoting using a singleton , however
then you miss the interop with this functionality to legacy apps and you
can`t pass guis to these clients ( wich could be done in VB6 )


regards

Michel Posseth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top