Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2005

Tip: Looking for answers? Try searching our database.

MC++, TAO CORBA and static instance problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jjr01@yahoo.com - 14 Sep 2005 14:00 GMT
I am writing an MC++ mixed-mode assembly (C++ and MC++) that will wrap
all TAO CORBA operations so that I can incorporate TAO into a C#
application.  I am constrained to use TAO by the customer, so I can't
use IIOP.NET.  I am constrained by the project to use C#, so I can't
use C++.

I am using VS.NET 2003, TAO 1.3a, Win2k sp4.

I have an interesting issue.  The TAO IDL compiler emits these
"Remote_Proxy_Broker" classes for each client-side interface.  These
classes each contain a "Factory Member function Implementation" of the
form:

_TAO_MyInterface_Remote_Proxy_Broker *
_TAO_MyInterface_Remote_Proxy_Broker::the_TAO_MyInterface_Remote_Proxy_Broker()
{
static ::_TAO_MyInterface_Remote_Proxy_Broker remote_proxy_broker;
return remote_proxy_broker;
}

Simple enough.  The method, which is static, declares a static instance
of its type, and returns it when called.  A singleton, in other words.

The problem is that my application crashes when trying to execute (i.e.
construct) the static instance.  The exception is a
System.NullReferenceException.  The call stack is something like:

  msvcr71.dll   __dllonexit
  mydll.dll     _onexit
  mydll.dll     atexit
  mscorwks.dll  7925de73

I can get around this problem by modifying the code and making it a
more traditional singleton, where the method declares a static pointer
to an instance, and news it if the pointer is NULL.  But this involves
hand-modifying code emitted by the TAO IDL compiler, and I am loath to
do this.

Even more fun, I found an example on the web
(http://kristopherjohnson.net/cgi-bin/twiki/view/KJ/ManagedChat) that
does the same thing with a simpler CORBA interface, and his code works
fine.

Any clues?  I have read KB 814472, which seems to say that statics in a
mixed mode DLL, which is what I have, is a very bad idea and the
statics don't get initialized properly by default.  But Kris Johnson's
example works.

Thanks.

reilly.
reilly - 14 Sep 2005 18:01 GMT
Of course, my post does contain a code error.  The return statement
should be:

  return &remote_proxy_broker;

Thanks.

reilly.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.