If it's compiled in release mode and not published, you can still get the line number. You just need to change a setting.
Go to the Project Properties
Click on the Compile tab
Click Advanced Compile Options.
Select Full or pdb-only from the Generate debug info ComboBox.
This will work if you are using the Build option.
If however, you are Publishing it, I don't think you'll be able to get the line number.
The best idea would be to put specific lines that could throw an exception into their own Try/Catch block.
I've seen instances like:
Try
Dim regKey as RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\DataCubeUtility", False)
Dim filePath as String = regKey.GetValue("DataCubeObjectPath")
Dim serializer as Serialization.XmlSerializer = Nothing
serializer = New Serialization.XmlSerializer(GetType(myCubeClasses.myCubeDef))
Dim dataFile as New FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.None)
myCubeType = serializer.Deserialize(dataFile)
dataFile.Close()
dataFile.Dispose
Catch ex as Exception
MessageBox.Show(ex.Message)
End Try
That is a huge waste of a Try/Catch block. The majority of that will never throw an error. You should break it down and check things yourself. Put the things that could throw an error into it's own Try/Catch block and then customize the message so you know where the error was...as in:
Dim regKey as RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\DataCubeUtility", False)
If regKey Is Nothing Then
MessageBox.Show("No valid Registry Key")
Return
End If
Dim filePath as String = regKey.GetValue("DataCubeObjectPath")
If Not File.Exists(filePath) Then
MessageBox.Show("File " & filePath & " does not exist")
Return
End If
Dim serializer as Serialization.XmlSerializer = Nothing
Try
serializer = New Serialization.XmlSerializer(GetType(myCubeClasses.myCubeDef))
Catch ex as Exception
MessageBox.Show("Unable to create the serializer" & vbNewLine & _
"ex.Message: " & ex.Message & vbNewLine & _
"ex.StackTrace: " & ex.StackTrace)
Return
End Try
If you did that, you wouldn't need the line numbers.