I've written a DLL that contains a bunch of classes. One of my methods validates the contents of a file and throws any necessary exceptions based on invalid content - I'm using a standard "throw new exception..." call ...the thing is, when my code reaches the line where the exception is thrown, my Visual Studio IDE hangs up on that line instead of the external call to my validate method.
A short conceptual example to demonstrate:
MyDLL content:
Public Class FileContent
Public Function ValidateFile(ByVal FileName As String) As Boolean
If Not System.IO.File.Exists(FileName) Then
Throw New Exception("File "& FileName & " doesn't exist.")
End If
End Function
End Class
Second project that contains reference to DLL
Imports MyDLL
Public Module Module1
Sub Main()
Dim oFC As New FileContent
oFC.ValidateFile("C:\FileThatDoesntExist.txt")
End Sub
End Module
So my IDE is actually pulling up the VB file that contains the DLL content and highlights the line in the ValidateFile instead of just hanging on the oFC.ValidateFile method line where the exception is thrown instead of the IDE hanging on the oFC.ValidateFile line in my calling application.
I just want user to have access to the any exceptions that are raised. Here if "C:\FileThatDoesntExist.txt" file does not exist then Dll throw exception which should be catch through Application.ThreadException.. How to Catch exception from DLL ?
-- Hiren Lad
A short conceptual example to demonstrate:
MyDLL content:
Public Class FileContent
Public Function ValidateFile(ByVal FileName As String) As Boolean
If Not System.IO.File.Exists(FileName) Then
Throw New Exception("File "& FileName & " doesn't exist.")
End If
End Function
End Class
Second project that contains reference to DLL
Imports MyDLL
Public Module Module1
Sub Main()
Dim oFC As New FileContent
oFC.ValidateFile("C:\FileThatDoesntExist.txt")
End Sub
End Module
So my IDE is actually pulling up the VB file that contains the DLL content and highlights the line in the ValidateFile instead of just hanging on the oFC.ValidateFile method line where the exception is thrown instead of the IDE hanging on the oFC.ValidateFile line in my calling application.
I just want user to have access to the any exceptions that are raised. Here if "C:\FileThatDoesntExist.txt" file does not exist then Dll throw exception which should be catch through Application.ThreadException.. How to Catch exception from DLL ?
-- Hiren Lad