[omniORB] VB -> CORBA (omniORB2) help needed - Please...

Ole Storm storm@ifad.dk
Tue, 15 Dec 1998 12:04:49 +0100


This is a multi-part message in MIME format.
--------------CB9969CD72F83FFE04B500D2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Greetings,

Recently I posted the following question, but got no response what so ever.
OK, I know that it is obscene to even consider calling CORBA objects from
Visual Basic, but never the less that is what I would like to do...

Maybe someone has an idea as to why my VB application goes down after the
DLL process is detached. Is there something omniORB specific I could do in
the 'case DLL_PROCESS_DETACH:' branch to avoid this??? Free some resources
etc.? Any ideas will be appreciated!

Best regards,

	Ole.
--------------CB9969CD72F83FFE04B500D2
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Received: from shallot.cam-orl.co.uk (shallot.cam-orl.co.uk [158.124.64.109])
	by hermes.ifad.dk (8.8.8/8.8.8) with ESMTP id QAA02217
	for <storm@ifad.dk>; Thu, 3 Dec 1998 16:13:05 +0100 (MET)
Received: from majordom by shallot.cam-orl.co.uk with local (Exim 2.02 #3)
	id 0zla5u-0005Di-00
	for omniorb-list-outgoing@orl.co.uk; Thu, 3 Dec 1998 14:51:02 +0000
Received: from hermes.ifad.dk ([130.225.136.3])
	by shallot.cam-orl.co.uk with esmtp (Exim 2.02 #3)
	id 0zla5s-0005DN-00
	for omniorb-list@orl.co.uk; Thu, 3 Dec 1998 14:51:00 +0000
Received: from ifad.dk (albani.ifad.dk [130.225.136.12])
	by hermes.ifad.dk (8.8.8/8.8.8) with ESMTP id PAA01613
	for <omniorb-list@orl.co.uk>; Thu, 3 Dec 1998 15:50:54 +0100 (MET)
Message-ID: <3666A4B7.D7BD4919@ifad.dk>
Date: Thu, 03 Dec 1998 15:48:23 +0100
From: Ole Storm <storm@ifad.dk>
Organization: IFAD
X-Mailer: Mozilla 4.5 [en] (WinNT; I)
X-Accept-Language: en
MIME-Version: 1.0
To: "omniorb-list@orl.co.uk" <omniorb-list@orl.co.uk>
Subject: [omniORB] Calling omniORB from Visual Basic...
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sender: owner-omniorb-list@orl.co.uk
Precedence: bulk
X-Mozilla-Status2: 00000000

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
---------------------------------------------------------------



--------------CB9969CD72F83FFE04B500D2--