Reputation: 10713
Here's what I have:
Debug.WriteLine("myMethod ok");
db.myTable.AddObject(new_item);
db.SaveChanges();
Debug.WriteLine("myMethod save changes");
And in the output window, I get:
"myMethod ok"
and nothing after that. So, AddObject and SaveChanges don;t throws exception because if they would, I would get that exception when I debug.
What could be the reason for this?
Upvotes: 0
Views: 145
Reputation: 127543
Re-reading your question, I realized it also could be a different issue. Perhaps db.SaveChanges();
hangs forever, Put a break point in at the top of the function and step through.
The exception may be being caught by a higher level try-catch block that is calling your function.
You can follow what is happening by enabling "Catch Exceptions on Thrown" by going to the Debug->Execptions...
dropdown menu and checking the Thrown
box for Common Language Runtime Exceptions.
This will cause your code to break on the exception, even if it is inside a try-catch block.
If you do not see the box for "User-Unhanded" to check like the below picture
go to Debug -> Options and Settings...
and be sure the box for "Enable Just My Code" is checked.
If it is not checked it will break on internal exceptions thrown by the .NET framework that do not represent problems, just control of flow logic that is implemented via exceptions in the framework (Most of the time it is a TimeOutExecption of some kind).
If the exception is still not being caught, try it again with "Just My Code" unchecked, just be aware of the possible "red-herring" exceptions the framework may throw.
Upvotes: 5
Reputation: 7
Check menu DEBUG - Exceptions and mark all Thrown checkboxes. Maybe than you will receive the Exception.
Upvotes: 0