Click here to Skip to main content
15,910,234 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionGet Error message in Catch part Pin
Vipul Mehta16-Jan-06 0:18
Vipul Mehta16-Jan-06 0:18 
AnswerRe: Get Error message in Catch part Pin
Robert Rohde16-Jan-06 0:30
Robert Rohde16-Jan-06 0:30 
GeneralRe: Get Error message in Catch part Pin
Vipul Mehta16-Jan-06 0:32
Vipul Mehta16-Jan-06 0:32 
AnswerRe: Get Error message in Catch part Pin
Guffa16-Jan-06 1:13
Guffa16-Jan-06 1:13 
GeneralRe: Get Error message in Catch part Pin
Vipul Mehta16-Jan-06 1:22
Vipul Mehta16-Jan-06 1:22 
AnswerRe: Get Error message in Catch part Pin
Guffa16-Jan-06 2:48
Guffa16-Jan-06 2:48 
GeneralRe: Get Error message in Catch part Pin
Robert Rohde16-Jan-06 1:16
Robert Rohde16-Jan-06 1:16 
GeneralRe: Get Error message in Catch part Pin
Colin Angus Mackay17-Jan-06 2:25
Colin Angus Mackay17-Jan-06 2:25 
Vipul Mehta wrote:
the reason for not creating Exception classes object is to avoid memory leakage


When an exception is thrown the stack starts to unwind. If you have created any objects that inherit the IDisposable interface then you you need to dispose of them as the stack is unwinding. That is what the finally block is for. Even if you don't catch an exception in a block of code, if it creates a disposable object it should have a finally block.

Dim someObject As SomeObjectClassThatInheritsIDisposable
Try
    ' Do stuff with someObject
    ' An exception may be thrown here
End Try
Finally
    ' Clear up someObject when finished with it.
    If Not someObject = Nothing Then
        someObject.Dispose()
    End If
End Finally

Just remember that the code in the finally block executes regardless of whether the exception was thrown or not. The idea is that this is where you place the clean up code that must be executed in order have disposable objects clean up properly regardless of the state of the system.

Sorry, I'm a C# developer, so my VB.NET may not be totally syntactically correct, but the essence of the idea is exactly the same.

ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell

QuestionPorting DLL from VB6 to .NET platform. Pin
Kedar Potdar15-Jan-06 23:18
Kedar Potdar15-Jan-06 23:18 
QuestionSystem.Web.Mail.SmtpMail.Send() Pin
User 58385215-Jan-06 19:14
User 58385215-Jan-06 19:14 
AnswerRe: System.Web.Mail.SmtpMail.Send() Pin
tarasn15-Jan-06 21:28
tarasn15-Jan-06 21:28 
AnswerRe: System.Web.Mail.SmtpMail.Send() Pin
Guffa15-Jan-06 21:33
Guffa15-Jan-06 21:33 
GeneralRe: System.Web.Mail.SmtpMail.Send() Pin
User 58385215-Jan-06 21:45
User 58385215-Jan-06 21:45 
QuestionRepacing DB with XML files? Pin
wmostafaw15-Jan-06 8:26
wmostafaw15-Jan-06 8:26 
GeneralRe: Repacing DB with XML files? Pin
silkkeng15-Jan-06 11:15
silkkeng15-Jan-06 11:15 
AnswerRe: Repacing DB with XML files? Pin
Mike Burroughs15-Jan-06 17:29
Mike Burroughs15-Jan-06 17:29 
QuestionAssembly Pin
Amit R15-Jan-06 5:35
Amit R15-Jan-06 5:35 
AnswerRe: Assembly Pin
Mike Burroughs15-Jan-06 17:37
Mike Burroughs15-Jan-06 17:37 
QuestionAnyone else having Errors with VS.NET 2005 Express Editions? Pin
M@dHatter14-Jan-06 17:57
M@dHatter14-Jan-06 17:57 
QuestionShared Method Pin
GaneshParam14-Jan-06 1:03
GaneshParam14-Jan-06 1:03 
AnswerRe: Shared Method Pin
Guffa14-Jan-06 9:06
Guffa14-Jan-06 9:06 
QuestionCan I pass remote objects as parameters? using .NET remoting Pin
fbrubacher13-Jan-06 11:32
fbrubacher13-Jan-06 11:32 
QuestionOnly on Friday the 13th: Worker Thread Duplicates Pin
RFID Chris13-Jan-06 9:29
RFID Chris13-Jan-06 9:29 
QuestionConvert .Net 2003 project to .Net 2005? Pin
Hardik Doshi12-Jan-06 19:23
Hardik Doshi12-Jan-06 19:23 
AnswerRe: Convert .Net 2003 project to .Net 2005? Pin
André Ziegler13-Jan-06 3:50
André Ziegler13-Jan-06 3:50 

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.