Click here to Skip to main content
15,890,282 members
Home / Discussions / C#
   

C#

 
AnswerRe: Ungroup shape in word file in c# Pin
Pankaj Saha23-Nov-09 3:42
Pankaj Saha23-Nov-09 3:42 
GeneralRe: Ungroup shape in word file in c# Pin
Abhishek Sur23-Nov-09 3:48
professionalAbhishek Sur23-Nov-09 3:48 
GeneralRe: Ungroup shape in word file in c# Pin
Pankaj Saha23-Nov-09 17:46
Pankaj Saha23-Nov-09 17:46 
QuestionGetting CurrentException without catch. Pin
Paulo Zemek23-Nov-09 1:48
mvaPaulo Zemek23-Nov-09 1:48 
AnswerRe: Getting CurrentException without catch. Pin
Richard MacCutchan23-Nov-09 2:06
mveRichard MacCutchan23-Nov-09 2:06 
AnswerRe: Getting CurrentException without catch. Pin
Luc Pattyn23-Nov-09 2:19
sitebuilderLuc Pattyn23-Nov-09 2:19 
AnswerRe: Getting CurrentException without catch. Pin
Shameel23-Nov-09 4:30
professionalShameel23-Nov-09 4:30 
GeneralRe: Getting CurrentException without catch. [modified] Pin
Paulo Zemek23-Nov-09 6:22
mvaPaulo Zemek23-Nov-09 6:22 
I know I can do this with try/catch/finally.
But I really want to know if there is any way to discover if the method I am is actually called by an exception (is inside a catch/finally) or not.

The purpose is to make the method simpler to use, as the caller of the method will not be required to pass the exception (or the boolean) as parameter.

A very ugly example:
using(var someTransaction = new MyTransaction())
{
... code here ...
someTransaction.Commit();
}

And then, in Dispose, I will check:
If the transaction was committed/rollbacked, do nothing.
If the transaction was not committed or rollbacked, but there is no exception, I will throw an exception telling that Commit or Rollback is required.
If there is already an exception, I will rollback and keep the original exception.

- Note: I know how to use try/catch/finally. But I really want to make the use of the code simpler for the others. using keyword looks nicer than try, catch and finally.

modified on Monday, November 23, 2009 12:38 PM

GeneralRe: Getting CurrentException without catch. Pin
The Man from U.N.C.L.E.23-Nov-09 6:52
The Man from U.N.C.L.E.23-Nov-09 6:52 
GeneralRe: Getting CurrentException without catch. Pin
Paulo Zemek23-Nov-09 7:03
mvaPaulo Zemek23-Nov-09 7:03 
GeneralRe: Getting CurrentException without catch. Pin
Shameel23-Nov-09 7:23
professionalShameel23-Nov-09 7:23 
AnswerRe: Getting CurrentException without catch. [modified] Pin
dojohansen23-Nov-09 8:25
dojohansen23-Nov-09 8:25 
AnswerRe: Getting CurrentException without catch: use Marshal.GetExceptionCode() Pin
Daniel Grunwald23-Nov-09 13:07
Daniel Grunwald23-Nov-09 13:07 
GeneralRe: Getting CurrentException without catch: use Marshal.GetExceptionCode() Pin
Paulo Zemek23-Nov-09 13:12
mvaPaulo Zemek23-Nov-09 13:12 
QuestionParameterless catch? Pin
Etienne_12323-Nov-09 0:20
Etienne_12323-Nov-09 0:20 
AnswerRe: Parameterless catch? PinPopular
dojohansen23-Nov-09 0:23
dojohansen23-Nov-09 0:23 
AnswerRe: Parameterless catch? Pin
Richard MacCutchan23-Nov-09 0:24
mveRichard MacCutchan23-Nov-09 0:24 
GeneralRe: Parameterless catch? Pin
Etienne_12323-Nov-09 0:29
Etienne_12323-Nov-09 0:29 
GeneralRe: Parameterless catch? Pin
dan!sh 23-Nov-09 0:35
professional dan!sh 23-Nov-09 0:35 
GeneralRe: Parameterless catch? Pin
dojohansen23-Nov-09 1:03
dojohansen23-Nov-09 1:03 
GeneralRe: Parameterless catch? Pin
Luc Pattyn23-Nov-09 1:10
sitebuilderLuc Pattyn23-Nov-09 1:10 
GeneralRe: Parameterless catch? Pin
Richard MacCutchan23-Nov-09 2:04
mveRichard MacCutchan23-Nov-09 2:04 
GeneralRe: Parameterless catch? Pin
Eddy Vluggen23-Nov-09 2:21
professionalEddy Vluggen23-Nov-09 2:21 
GeneralRe: Parameterless catch? Pin
Saksida Bojan23-Nov-09 6:15
Saksida Bojan23-Nov-09 6:15 
GeneralRe: Parameterless catch? Pin
Eddy Vluggen23-Nov-09 7:46
professionalEddy Vluggen23-Nov-09 7:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.