Share via


<assert> Element

Specifies whether to display a message box when you call the Debug.Assert method; also specifies the name of the file to write messages to.

<configuration>
   <system.diagnostics>
      <assert>

<assert assertuienabled="true|false" logfilename="file name"/>

Optional Attributes

Attribute Description
assertuienabled Specifies whether to display a message box when the Debug.Assert method evaluates to false.
true
Displays the message box. This is the default.
false
Does not display the message box.
logfilename Specifies the name of the file to write the message to if Debug.Assert evaluates to false.

Remarks

Both attributes in the <assert> element are optional. You can disable message boxes without specifying a file to write the messages to, or you can specify a file to write messages to while leaving message boxes enabled.

Example

The following example shows how to disable displaying message boxes when you call Debug.Assert and write the messages to c:\log.txt.

<configuration>
   <system.diagnostics>
      <assert assertuienabled="false" logfilename="c:\log.txt"/>
   </system.diagnostics>
</configuration>

Configuration File

This element can be used in the machine configuration file (Machine.config) and the application configuration file.

See Also

Trace and Debug Settings Schema | Debug Class