Dynamics 365 Business Central: How to set your custom Method (procedure) and Variable non-debuggable (NonDebuggable Attribute)

Dynamics 365 Business Central

Hi, Readers.
Today I would like to talk about how to set your custom Method (procedure) and Variable non-debuggable.

As you might know, we can use “resourceExposurePolicy” setting for better control of source access from Business Central 2021 wave 2 (BC19).

resourceExposurePolicy: Defines the accessibility of the resources and source code during different operations.

So, to allow debugging into your extension, when the extension is taken as a dependency, you can set the allowDebugging flag, otherwise debugging isn’t allowed.
More details: ‘showMyCode’ -> ‘resourceExposurePolicy’

In this post, I would like to share a more detailed control, NonDebuggable Attribute.

NonDebuggable Attribute: Specifies that the annotated symbol will not be available to the debugger. E.g. methods can’t be stepped through and variables can’t be inspected.

Applies To:

  • Variable
  • Method

Syntax: [NonDebuggable]

Variable:

Method:

Please note that NonDebuggable Attribute is also working within the same Extension. Let’s look at three examples.

1. Set breakpoint for the NonDebuggable method.

Test Video: The NonDebuggablemethod can’t be stepped.

2. Error in the NonDebuggablemethod (No breakpoint)

Test Video: The debugger will not break on the error in the NonDebuggablemethod.

3. Test NonDebuggable variable.

Test Video: The NonDebuggable variable cannot be found in Debugger.

It’s pretty easy, right, but be careful to set it up only when you really need it, as it can make investigating the problem more complicated. Give it a try!!!😁

PS:
Unless you’ve specified the [NonDebuggable] attribute on methods and variables, setting the allowDebugging to true will allow stepping into this code. If you, however, have marked the methods and variables marked with the [NonDebuggable] attribute, these will remain non-debuggable.

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL