.NET

.NET

Reply
Active Contributor
jimmie_fulton
Posts: 44
Registered: ‎04-06-2005
Message 1 of 1 (234 Views)

TransactionManager.StartTransation() causes null object error?

234 Views, 0 Replies
02-22-2006 11:43 AM
I have an event handler connected to the Database.ObjectAppended to watch when a particular object type has been appended to the database. Within the event handler, it seems that the database is in such as state that I can't get a transaction to query the database with; it causes a null object exception when I call StartTransaction() on the database's TransactionManager. Any ideas why?

// ObjectEventHandler event handler
private static void Database_ObjectAppended(object sender, ObjectEventArgs e)
{
Database database = sender as Database;
PropertySet propertySet = e.DBObject as PropertySet;
if (propertySet != null && database != null)
{
ObjectId sheetnoteSetDefId = ObjectId.Null;
// *** Error happens on next line ***
using (Transaction trans = database.TransactionManager.StartTransaction())
{
using (DictionaryPropertySetDefinitions propertySetDefIds = new DictionaryPropertySetDefinitions(database))
{
foreach (ObjectId propertySetDefId in propertySetDefIds.Records)
{
PropertySetDefinition propertySetDef = (PropertySetDefinition)trans.GetObject(propertySetDefId, OpenMode.ForRead);
if (propertySetDef.Name.ToLower() == "sheetnote_data")
{
sheetnoteSetDefId = propertySetDef.ObjectId;
break;
}
}
}
if (propertySet.PropertySetDefinition == sheetnoteSetDefId)
{
int number = (int)propertySet.GetAt(propertySet.PropertyNameToId("Number"));
string text = (string)propertySet.GetAt(propertySet.PropertyNameToId("Text"));
SheetnoteInfo sheetnoteInfo = new SheetnoteInfo(number, text);
sheetNoteControl.AddSheetnote(sheetnoteInfo);
}
}
}
}
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.