Exception not thrown at actual place of exception
Exception not thrown at actual place of exception
Exception not thrown at actual place of exception
Exception not thrown at actual place of exception
Exception not thrown at actual place of exception
Exception not thrown at actual place of exception Exception not thrown at actual place of exception Exception not thrown at actual place of exception Exception not thrown at actual place of exception Exception not thrown at actual place of exception Exception not thrown at actual place of exception Exception not thrown at actual place of exception Exception not thrown at actual place of exception
Exception not thrown at actual place of exception Exception not thrown at actual place of exception
Exception not thrown at actual place of exception
Go Back  Xtreme Visual Basic Talk > > > Exception not thrown at actual place of exception


Reply
 
Thread Tools Display Modes
  #1  
Old 10-12-2014, 06:05 AM
jaccog's Avatar
jaccog jaccog is offline
Regular
 
Join Date: Mar 2005
Location: The Netherlands
Posts: 96
Unhappy Exception not thrown at actual place of exception


Hi,

I'm having some strange issues and I'm not sure why.

Let's say I have a Function that gets an item from a dictionary like this:
Code:
Function GetCallsign( Key as string) as string
Return CallSigns("A")
End Function
The line above would Return "Alpha" for instance.

When the dictionary does not contain the "A" key, it would throw an exception.

Now, when I call this function from within another sub, the exception gets thrown in the calling sub but not in the GetCallsign function. How come?
The debugger only tells me the code-line of the calling sub, not the line in the GetCallSign function.

Sometimes the call to GetCallsign is nested 5 subs deep and when the exception raises I have to debug step-by-step to find that the reason is within the GetCallsign function. How can this be?

Did I mess up my exception trapping settings in VB.NET maybe? I'm using Visual studio 2010.

Thanks!
__________________
Jacco.
-The one who says it cannot be done should never interrupt the one who is doing it-
Reply With Quote
  #2  
Old 10-12-2014, 07:40 AM
snarfblam's Avatar
snarfblamException not thrown at actual place of exception snarfblam is offline
Senior Contributor

Forum Leader
* Expert *
 
Join Date: Apr 2005
Location: USA
Posts: 896
Default

Make sure the build configuration is set to debug. If you're running a release build, a simple function like this will generally be inlined as an optimization. There are other scenarios where a function can be "invisible" to the debugging UI (things like "Just My Code" and the DebuggerStepThrough attribute), but in this case, inlining is the only likely culprit I can think of.
__________________
C# _VB.NET _
Reply With Quote
  #3  
Old 10-12-2014, 08:09 AM
jaccog's Avatar
jaccog jaccog is offline
Regular
 
Join Date: Mar 2005
Location: The Netherlands
Posts: 96
Default

Thanks Snarfblam,

I was/am running in the development environment, and also in debug config.
__________________
Jacco.
-The one who says it cannot be done should never interrupt the one who is doing it-
Reply With Quote
  #4  
Old 10-12-2014, 08:19 PM
snarfblam's Avatar
snarfblamException not thrown at actual place of exception snarfblam is offline
Senior Contributor

Forum Leader
* Expert *
 
Join Date: Apr 2005
Location: USA
Posts: 896
Default

Well, then, are you sure you don't have optimizations enabled for the debug configuration?
__________________
C# _VB.NET _
Reply With Quote
  #5  
Old 10-13-2014, 01:09 AM
jaccog's Avatar
jaccog jaccog is offline
Regular
 
Join Date: Mar 2005
Location: The Netherlands
Posts: 96
Default

Yup, The checkbox is unchecked.

It also seems that, if the exception occurs, the calling Sub exits and thus bypassing code that should follow. All this without raising an exception.
I just discovered this behaviour since I included an extra Try_catch block which now seems to catch exceptions in the calling sub.


*Weird*
__________________
Jacco.
-The one who says it cannot be done should never interrupt the one who is doing it-
Reply With Quote
  #6  
Old 10-13-2014, 01:45 PM
passel's Avatar
passelException not thrown at actual place of exception passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,024
Default

I'm not sure I understand the issue.
If you get an exception in code, it will be raised to what ever level you have an exception handler that encompasses it.
So, if you don't have a handler in the subroutine it will be raised to the calling subroutine. It that routine doesn't have an exception handler, it will be raised to the next level in the call stack.
Only if the exception is not within the scope of a handler that you wrote, will it be raised out to the IDE to handle, which will point you to where the exception occurred.

I do believe there is an option you can turn on so that the IDE captures all exceptions at occurrence, rather than being raised up to your encompassing handler, but I might be confusing that with another IDE and language.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Exception not thrown at actual place of exception
Exception not thrown at actual place of exception
Exception not thrown at actual place of exception Exception not thrown at actual place of exception
Exception not thrown at actual place of exception
Exception not thrown at actual place of exception
Exception not thrown at actual place of exception Exception not thrown at actual place of exception Exception not thrown at actual place of exception Exception not thrown at actual place of exception Exception not thrown at actual place of exception Exception not thrown at actual place of exception Exception not thrown at actual place of exception
Exception not thrown at actual place of exception
Exception not thrown at actual place of exception
 
Exception not thrown at actual place of exception
Exception not thrown at actual place of exception
 
-->