[gme-users] GME BON2 Add-on throws an exception everytime that can't be caught!!!!!

James Hill hillj at isis.vanderbilt.edu
Wed Jan 11 19:16:58 CST 2006


Hello all,

I am creating an add-on and its throwing an exception that I can't
catch. I have tried adding a try...catch block around my code and it's
still failing. The exception is apparently being thrown deep inside of
BON and within the scope of the method that calls
Component::objectEventPerformed (). The exception that is occuring is
**Unhandled and unknown exception was thrown in BON2Component
ObjectEvent!** This exception is thrown everytime I try to import an XME
file. The add-on works fine while the project is open and being used. I
have enclosed the source code since it's small. Any assistance as to
what I am doing wrong is greatly appreciated.

void Component::objectEventPerformed( Object& object, unsigned long
event, VARIANT v )
{
  try
  {
    // Get the name of the object type. Only monitor <Component> 
    // and <ComponentAssembly> objects.
    std::string name = object->getObjectMeta ().name ();

    if (name == "Component" || name == "ComponentAssembly")
    {
      BON::FCO fco = object;
      BON::Attribute uuid = fco->getAttribute ("UUID");

      if (uuid)
      {
        // We only handle the creation events at this stage.
        if (event == MON::OET_ObjectCreated)
        {
          // Create an UUID and add the <uuid_manager_> event
          // listener to the object.
          uuid->setStringValue (PICML::CreateUuid ());     
        }
        else if (event == MON::OET_AttributeChanged)
        {
          // Validate the UUID of the object.
          if (!PICML::ValidUuid (uuid->getStringValue ()))
          {
            uuid->setStringValue (PICML::CreateUuid ());
          }
        }
      }
    }
  }
  catch (...)
  {
    // This does not catch the exception!!! It's being caught in
ComponentObj.
    // Some local variable defined before invoking this method throws an
exception
    // whenever it is destroyed. I have no idea why?!?!?!
    AfxMessageBox ("Gotcha");
  }

Thanks,

James

--------------------------------------------

James H. Hill - Ph.D. Student
Research Assistant - ISIS / DOC Group

Microsoft Student Ambassador
Department of EECS / Computer Science Program
Vanderbilt University, Nashville, TN

Email: j.hill at vanderbilt.edu 



More information about the gme-users mailing list