How to create what VB6 calls an 'ActiveX EXE'

  • Thread starter Thread starter Dan Holmes
  • Start date Start date
D

Dan Holmes

I know how to make my .net classes visible to COM but can c#/.net create an out of process server that is accessible via
COM?

dan
 
Dan,

COM interop doesn't support creating an out of process server in .NET.
You will have to use unmanaged code to create the host, and then you can
provide the implementation through .NET in the host.
 
Nicholas Paldino said:
Dan,

COM interop doesn't support creating an out of process server in .NET.
You will have to use unmanaged code to create the host, and then you can
provide the implementation through .NET in the host.

If it is an out-of-process that is desired rather than COM automation then
a COM+ application could be used.
 
Anthony,

It could be, but that is not what the OP asked (he was very specific
about an out of process COM server/ActiveX EXE). I agree that a COM+
application is a much, MUCH better alternative though (depending on the
need).
 
Nicholas said:
Anthony,

It could be, but that is not what the OP asked (he was very specific
about an out of process COM server/ActiveX EXE). I agree that a COM+
application is a much, MUCH better alternative though (depending on the
need).
The bottom line is i need an out of process host for a COM dll. The calling process will be SQL server and i don't want
any failures from the COM dll to create a SQL crash.

I am open to other ways. I spoke of an ActiveX EXE because that is what my boss asked for. If that isn't possible what
do you recommend?

I am going to call this from either SQLCLR or the sp_OA* SQL procs. I would prefer as much a .net solution as possible
but will take whatever is the "best" as defined by the balance of best practice and quickest to implement.

thanks for the help.

dan
 
Dan,

sp_OA is a REALLY bad idea. As well as out of process calls on the same
machine for SQL Server, IMO. Since you can do SQL CLR, I suggest you use
that, as SQL Server has a great level of control over the CLR, and can
control the memory management of the CLR, as well as threads and the like so
as to optimize its use in SQL Server.
 
Nicholas said:
Dan,

sp_OA is a REALLY bad idea. As well as out of process calls on the same
machine for SQL Server, IMO. Since you can do SQL CLR, I suggest you use
that, as SQL Server has a great level of control over the CLR, and can
control the memory management of the CLR, as well as threads and the like so
as to optimize its use in SQL Server.
I agree on all accounts but the COM dll is unmananged code. I have already written a SQLCLR proc that will crash SQL
using that dll.

I don't have time to rewrite the DLL in managed code for SQLCLR consumption. I don't want that dll to crash the SQL
process. I think my best choice is an out of process call from SQLCLR. Since .net interop can't create an out of
process server what are my options?

dan
 
Dan,

In this case, hosting in COM+ would be the best solution, and then
making the calls to the COM+ service through CLR integration in SQL Server,
IMO.
 
Dan Holmes said:
I agree on all accounts but the COM dll is unmananged code. I have
already written a SQLCLR proc that will crash SQL using that dll.

I don't have time to rewrite the DLL in managed code for SQLCLR
consumption. I don't want that dll to crash the SQL process. I think my
best choice is an out of process call from SQLCLR. Since .net interop
can't create an out of process server what are my options?

Your original post clouded the issue. It sounded as though you wanted to
write some .NET code that could be accessed by unmanaged COM code. What it
turns out to be is a COM dll that you want to access from .NET. You don't
want rogue code in the COM DLL trashing the process in which the .NET code
runs in.

Answer install COM dll in a COM+ server app.
 
Nicholas said:
Dan,

In this case, hosting in COM+ would be the best solution, and then
making the calls to the COM+ service through CLR integration in SQL Server,
IMO.
Is there MS documentation that says out of process ActiveX servers can't be created by .net COM interop? I will have to
prove this to my boss.

dan
 
Couldn't the O/P also simply create a wrapper COM component as well? He
said he knows how to make the objects available to COM, create an
ActiveX.exe and wrap the method calls there. COM+ to means hosted service
supporting impersonation, it's for the big dogs. ActiveX.exe to me means
simple out of process support.

Sample:

..Net -->
class worker
public event workstatus(object, eventargs)
public event workcomplete(object, eventargs)
public sub Init(...,...,...)
public sub dowork()
end class

VB --> ActiveX exe

workerWraper Class
'Doesn't support event automation so implementing worker specifically
wouldn't work.

private withevents pobjWorker as worker

public event workstatus(eventargs)
public event workcomplete(eventargs)

public sub init()
set pobjWorker = new Worker
pobjWorker.Init()
end sub

public sub dowork()
pobjWorker.DoWork()
end sub

sub pobjWorker_WorkStatus(object, args)
sub pobjWorker_WorkComplete(object, args)

Anyway, just an alternative thought.
 
amdrit said:
Couldn't the O/P also simply create a wrapper COM component as well? He
said he knows how to make the objects available to COM, create an
ActiveX.exe and wrap the method calls there. COM+ to means hosted service
supporting impersonation, it's for the big dogs. ActiveX.exe to me means
simple out of process support.

Its simpler to dump the COM dll into a COM+ application. I don't think its
for the "big dogs" and there is no need to do clever stuff with
impersonation, roles, security etc.
 
Back
Top