المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : who killed my app!? [modified]



C# Programming
03-30-2009, 12:25 PM
hello, Can NHibernate exit your app without throwing an exception?

I'm debugging a console app and

void main(...)
{
try {
IPerson oParent = LoadPerson(123);

} catch(Exception ex)
{
Console.WriteLine(ex.ToString()); // this was never hit!?
}
return;
}

public IPerson LoadPerson(long nId)
...
try {

// DAO call which uses NHibernate ISession.Get(nId). Then "Children" are retrieved by another mechanism, but initial ISession.Get and subsequent loading of children are two separate member functions wrapped under single transaction scope (i.e. not NHibernate... long story short, it uses a self-referencing table to hold parent-child relationship. This table uses a different mapping file. Retrieved oChild.Parent is set to oParent which I think is... the primarily culprit)

using (oScope = new TransactionScope(TransactionScopeOption.Required))
{
IPerson oParent = Session.Get(nId);

LoadChildren(oParent);

foreach(IPerson oChild in oParent.Children)
{
oChild.Parent = oParent; // If I comment out this line my app won't "exit silently" (not immediately, but after exit from "LoadPerson")!! Question is why!?

oChild.Parent = new Person(); // Event this would save the app from silently exiting (after exit from "LoadPerson")

}
}

} catch (Exception ex)
{
Console.WriteLine(ex.ToString()); // this was never hit?!
}

returns oParent;
}


Any suggestion as to posssibility of NHibernate causing my WIN32 console app to exit silently? I have catch(Exception) on all levels but still I didn't manage to catch any exception and therefore don't know what killed it... I initially suspected loading children is a recursive ops but if infinitely recursion was the cause of death I should have a StackOverflowException do I? But I have nothing. I understand you can't "catch" a StackOverflowException" but still if you run app on debugger, debugger will be able to tell you that under all circumstances right? (I tested this on another simple toy app)

I am most suspicious you can't really assigned oParent to Child.Parent attribute within same transaction scope - even though oParent loaded first.

oChild.Parent = oParent;



Many thanks.

dev

modified on Monday, March 30, 2009 4:04 AM