[omniORB] Calling omniORB from Visual Basic...
Ole Storm
storm@ifad.dk
Thu, 03 Dec 1998 15:48:23 +0100
Greetings omniORB'ers
I would like to be able to call a Corba object from Visual Basic. I am aware
that one way to achieve this would be to "wrap" my Corba object in a COM
interface, but I think it would take me too long to do this...
What I would like to do in stead is the following:
Write a C++ DLL that makes the appropriate calls to the ORB and the Corba
object, and then access this DLL from VB.
I have managed writing a simple DLL, and it is actually possible to call its
exported functions from VB. However, when I try to make a omniORB specific
call in the DLL things start to go wrong. For instance I will initialize the
ORB and the BOA in the DllMain like this:
BOOL APIENTRY DllMain(HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
int dummy = 0;
switch( ul_reason_for_call ) {
case DLL_PROCESS_ATTACH:
_the_orb = CORBA::ORB_init(dummy, NULL, "omniORB2");
_the_boa = _the_orb->BOA_init(dummy, NULL, "omniORB2_BOA");
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
What happens is this: The first time VB calls a function in the DLL, the ORB
and BOA are initialized all-right, and subsequent Corba calls are OK as
well. When the VB "kode" is finished (I use an Excel macro to test the DLL)
the DllMain function is called with ul_reason_for_call=DLL_PROCESS_DETACH -
which seems OK as well.
Now I simply wait... After 20-30 secconds my VB application (here Excel)
simply goes down - just like that. If I omit the calls to initialize the ORB
and BOA everything works fine!
I have read the notes in CORBA_sysdep.h stating that USE_stub_in_nt_dll
should be defined before including the stub headers (.hh) and I compile the
stub cc files with the macro-option -D_OMNIORB2_STUB_DLL
Any clues as to what might be wrong???
Maybe something should be released or destroyed when DllMain is called with
the DLL_PROCESS_DETACH flag???
Any help will be appreciated!
Best regards,
Ole.
---------------------------------------------------------------
Ole Storm
The Institute of Applied Computer Science (IFAD)
Forskerparken 10, DK-5230 Odense M, Denmark
Phone: +45 6315 7134, Fax: +45 6593 2999, Email: storm@ifad.dk
WWW: http://www.ifad.dk
---------------------------------------------------------------