[omniORB] CosNaming::NamingContext::AlreadyBound& ex

marecky m_are_k at o2.pl
Fri Feb 27 10:10:58 GMT 2009


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



More information about the omniORB-list mailing list