Skip to main content
Summary This article clarifies the use of ORB_init() inside a Dynamic Load Library (DLL).
Article Number 36408
Environment Orbix 6.3 C Windows
Question/Problem Description CORBA::ORB_init() hangs when called inside a DLL's DllMain() method.

Where should ORB_init() be called in order to initialize an ORB?
Clarifying Information

The DllMain() is an optional entry point into a dynamic-link library (DLL).

When the system starts or terminates a process or thread, it calls the entry-point function for each loaded DLL using the first thread of the process. The system also calls the entry-point function for a DLL when it is loaded or unloaded using the LoadLibrary and FreeLibrary functions.

There are serious limits on what can be done in a DLL entry point. If more complex initialization is required, create an initialization routine for the DLL, this initialization routine should be called by applications before calling any other routines in the DLL.

 

Error Message
Defect/Enhancement Number
Cause
Resolution ORB_init() must not be called inside a DLL's DllMain() method, as this can cause serious issues and deadlocks due to the loader lock that DLLMain() is called under.

An ORB should be initialized by calling ORB_init() from the main function of an application.
Workaround
Notes For further information, please see
"Best Practices for Creating DLLs":
http://msdn.microsoft.com/en-us/library/windows/hardware/gg487379.aspx
and DLLMain docs at
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682583(v=vs.85).aspx
Attachment
Created date: 22 November 2012
Last Modified: 12 February 2013
Last Published: 22 November 2012
First Published date: 22 November 2012

#Orbix
#KnowledgeDocs