Debugging code in Visual Studio - Breakpoint only hits the 1st time? - InfoPath Dev
in

InfoPath Dev

Debugging code in Visual Studio - Breakpoint only hits the 1st time?

Last post 07-20-2016 06:35 PM by meissen. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 07-19-2016 01:13 PM

    Debugging code in Visual Studio - Breakpoint only hits the 1st time?

    Hi all,
    Trying to debug some VB code I've written for a field's Change event. The 2nd time the code fires I get an error but the error window is screwed up and you can't actually read the error message in the window, it's cut off.

    I set up a break point in the code for the field's Change event and it hits the first time I change the field's value -- I can step through the code perfectly. But then when Visual Studio returns me to the form and I change the value a 2nd time the breakpoint does NOT hit even though the code attempts to execute and errors out.

    Any ideas on how to hit the breakpoint every time the code fires? I *am* running as debug state and using the "Start" button in Visual Studio. Like I said - the breakpoint works the first time I change the field, but the 2nd time I change the field it doesn't break. Please advise.
  • 07-19-2016 03:00 PM In reply to

    Re: Debugging code in Visual Studio - Breakpoint only hits the 1st time?

    Weird - I've never seen that. Where's your breakpoint? What's the code? I'm wondering if you have some conditions so that the break point isn't reached the second time. You can always use a message box to show the error message, if you have to (if this is a browser form, change the compatibility temporarily, or put the error message in a form field).
    Hilary Stoupa

  • 07-19-2016 08:05 PM In reply to

    Re: Debugging code in Visual Studio - Breakpoint only hits the 1st time?

    Here's the VB code -- no matter where in the public sub I put the breakpoint it fails to "hit" the 2nd time through.

    It's pretty simple code that's just gathering field values from various points in the form, then looping through the code to add/remove sections.
  • 07-20-2016 10:03 AM In reply to

    Re: Debugging code in Visual Studio - Breakpoint only hits the 1st time?

    So this runs when my:myFields/my:HiddenFields/my:GCCXElements changes? Are you certain the field is changing again?
    Hilary Stoupa

  • 07-20-2016 12:21 PM In reply to

    Re: Debugging code in Visual Studio - Breakpoint only hits the 1st time?

    Well I feel like an idiot lol. The rule that triggers the VB code updates all of the fields that are then imported into variables, including GCCX, but what I failed to take into consideration is that 0 being "updated" to 0 the 2nd time probably doesn't register as a "change" after all... which would then explain why the breakpoint doesn't "hit." Thanks for pointing me in the right direction - looks like I need to change the trigger for the vb code to run.
  • 07-20-2016 12:33 PM In reply to

    Re: Debugging code in Visual Studio - Breakpoint only hits the 1st time?

    Mystery solved! I see the same thing with rules - where there is confusion as to why a rule didn't fire & it turns out the field w/ the rule didn't change. Yah, reset that field after your code completes - maybe go with a try/catch/finally and reset in the finally so it is always ready to go again. :)
    Hilary Stoupa

  • 07-20-2016 06:35 PM In reply to

    Re: Debugging code in Visual Studio - Breakpoint only hits the 1st time?

    Thanks Hilary - that was 100% the issue. I created a new rule which adds all of those "Elements" fields together and that field changing is now my trigger for the VB code. It's working again! I have a feeling I'm really pushing some limits of InfoPath with this form and am worried I'm going to hit a wall where my automation is not going to work anymore... especially with the rules of how many changes can be made without user interaction. Knock on wood so far so good. Next big hurdle will be getting the code-enabled form published to SharePoint!
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.