![]() Choose Debug configuration for the full debugging experience.To build the solution, choose either the Debug (default) or Release configuration, and then select Build > Rebuild Solution. Throw new NullReferenceException("this is the exception thrown by the console app") Replace the Main() method with the following code, which prints a line to the console and then throws a NullReferenceException: static void Main(string args)Ĭonsole.WriteLine("we will now throw a NullReferenceException") When the project opens in Visual Studio, open the Program.cs file. For more information about creating projects in Visual Studio, see Walkthrough: Create a simple application. In Visual Studio, create a C# console app ( File > New > Project > Visual C# > Console Application) named ThrowsNullException. Make sure Just-In-Time debugging is enabled in Tools > Options > Debugging > Just-In-Time.įor this example, you'll make a C# console app in Visual Studio that throws a NullReferenceException. If you don't have Visual Studio, you can download the free Visual Studio Community Edition. You must have Visual Studio installed to follow these steps. This example walks you through Just-In-Time debugging when an app throws an error. If you want to debug a non-optimized release build, however, you must set DebuggableAttribute by adding the following line in your app's AssemblyInfo.cpp file: įor more information, see DebuggableAttribute. If you compile with /Zi and without /Og, the compiler sets this attribute for you. In a C++ Windows Form application, also set DebuggableAttribute to true in a. exe.config file, set the jitDebugging value to true: To enable Just-In-Time debugging instead of standard Windows Form error handling, add these settings: If a Windows Forms app throws an unhandled exception, it shows the following dialog: Make sure not to delete or change any other registry keys.Įnable Just-In-Time debugging of a Windows Formīy default, Windows Form apps have a top-level exception handler that lets the app keep running if it can recover. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\DbgManagedDebugger HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug\DebuggerĪlso delete the following registry entries if they exist: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\DbgManagedDebugger In the Registry Editor window, locate and delete the following registry entries if they exist: To disable Just-In-Time debugging by editing the registry:įrom the Windows Start menu, run the Registry Editor ( regedit.exe). If Visual Studio is no longer installed, you can disable Just-In-Time debugging by editing the Windows registry. Just-In-Time debugging may still be enabled even if Visual Studio is no longer installed on your computer. ![]() Disable Just-In-Time debugging from the Windows registry If you enable the Just-In-Time debugger, but it doesn't open when an app crashes or errors, see Troubleshoot Just-In-Time debugging. In the Enable Just-In-Time debugging for these types of code box, select the types of code you want Just-In-Time debugging to debug: Managed, Native, and/or Script. If the Just-In-Time menu option is not shown, make sure the Just-In-Time debugger is installed using the Visual Studio Installer.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |