Discussion:
[omniORB] CosNaming::NamingContext::AlreadyBound& ex
marecky
2009-02-27 15:11:05 UTC
Permalink
Hi all
I try to develop a small Win32 application using omniORB and Visual
Studio 2008 (VS9) . I successfully finished a console
application, but when I try to use the same stubs and skeletons in Win32
application I get an error from VC:
"System.Runtime.InteropServices.SEHException","
CosNaming::NamingContext::AlreadyBound at memory location..."
In a code I can see, that this exception is managed, and I do not
understand why is raised in Win32 project and not in console
application. I attach the piece of code where it breaks:
try {
// Bind a context called "Win32Corba" to the root context:

CosNaming::Name contextName;
contextName.length(1);
contextName[0].id = (const char*) "Win32Corba"; //
string copied
contextName[0].kind = (const char*) "Win32Corba_context"; //
string copied
// Note on kind: The kind field is used to indicate the type
// of the object. This is to avoid conventions such as that used
// by files (name.type -- e.g. test.ps = postscript etc.)

CosNaming::NamingContext_var Win32CorbaContext;
try {
// Bind the context to root.
Win32CorbaContext = rootContext->bind_new_context(contextName);
}
catch(CosNaming::NamingContext::AlreadyBound& ex) {
// If the context already exists, this exception will be raised.
// In this case, just resolve the name and assign testContext
// to the object returned:
CORBA::Object_var obj;
obj = rootContext->resolve(contextName);
Win32CorbaContext = CosNaming::NamingContext::_narrow(obj);
if( CORBA::is_nil(Win32CorbaContext) ) {
cerr << "Failed to narrow naming context." << endl;
return 0;
}
}
Have someone met a similar problem? Thank you in advance for help.
MC
Duncan Grisby
2009-03-13 18:46:26 UTC
Permalink
Post by marecky
I try to develop a small Win32 application using omniORB and Visual
Studio 2008 (VS9) . I successfully finished a console
application, but when I try to use the same stubs and skeletons in
"System.Runtime.InteropServices.SEHException","
CosNaming::NamingContext::AlreadyBound at memory location..."
In a code I can see, that this exception is managed, and I do not
understand why is raised in Win32 project and not in console
It's probably due to mixing different exception handling modes. VC++
makes life really hard by offering several incompatible exception
handling systems. You must compile all your code with the same settings
used to compile omniORB itself. Ensure the compiler command line options
for your Win32 project are the same as those for the working console
application.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Loading...