Coffee Break Troubleshooting Part IV: Windows Error Reporting and Collecting Crash Dumps


For troubleshooting issues with Microsoft products in general, you can use Windows Error Reporting to report computer problems to Microsoft. Microsoft uses the problem reports to try to match descriptions of each problem to a solution. This feature is enabled by default, and generates detailed reports about the problem.

To troubleshoot application instability issues, we will often need crash dumps in addition. For Microsoft Dynamics NAV, a full crash dump might be required to provide sufficient details to isolate and fix the problem. Once crash dump is collected, contact support and provide the dump. There are number of ways and tools to collect a crash dump, but we’ll look at how to automate this action in a very simple way.

Enable Windows Error Reporting

This feature is enabled by default, but you can opt to turn it off. To check if the feature is enabled, run this command:

Get-WindowsErrorReporting

To enable and then disable Windows Error Reporting, run

Enable-WindowsErrorReporting
Disable-WindowsErrorReporting

This will ensure a detailed report is generated when you encounter instability with your Dynamics NAV (or any other) application. You can read more about information collection and how data are protected here.

The information is collected in one for the following categories:

  • Per user archived Windows Error Reports
  • Per user queued Windows Error Reports
  • System archived Windows Error Reports
  • System queued Windows Error Reports

And stored at:

  • %USERPROFILE%\AppData\Local\Microsoft\Windows\WER\ReportArchive
  • %USERPROFILE%\AppData\Local\Microsoft\Windows\WER\ReportQueue
  • %ALLUSERSPROFILE%\Microsoft\Windows\WER\ReportArchive
  • %ALLUSERSPROFILE%\Microsoft\Windows\WER\ReportQueue

The report will contain details registered in application event view, loaded modules, but can also contain logs, portions of registry, portions of forms working at, … Note that only non-personal data is sent to Microsoft

For Dynamics NAV, you must collect and submit a full dump in addition to the report.

To collect the full crash dump:

#Modify registry keys to enable automatic dump collection
Set-Location HKLM:

#test that path exists in regedit
#test-path ".\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps"
$keypath = ".\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps"

#see list of executables already configured for dump collection
Get-ChildItem -Path $keypath

'Add a key for your executable under LocalDumps folder to enable dump collection. 
For the Dynamics NAV Windows client, the name of the key is Microsoft.Dynamics.NAV.Client.exe. 
For Dynamics NAV Server, that value is Microsoft.Dynamics.NAV.Server.exe. 
For the development environment, it's finsql.exe. 
In Dynamics NAV 2016, x64 client is the default client, and if you are using x86 client, the name is Microsoft.Dynamics.NAV.Client.x86.exe.'
New-Item -Path $keypath -Name Microsoft.Dynamics.NAV.Client.exe

'add DumpCount, DumpType (2 for full dump) and Output Path for dump files.
If no output path is specified, default is used.
default path is %USERPROFILE%\AppData\Local\CrashDumps 

It is convenient to specify a separate folder when troubleshooting so you collect all data relevant to one problem in one location. 
The dumps can be rather large and consume disk space. 
You can delete the files collected by WER using the Disk Cleanup tool, as a part of regular Windows maintenance. 
If you direct your application dumps to dedicated folder, you can remove that data once the problem is reported.'
New-ItemProperty -Path $keypath\Microsoft.Dynamics.NAV.Client.exe -Name DumpCount -PropertyType "DWORD" -Value 10

# 2 is for full dump
New-ItemProperty -Path $keypath\Microsoft.Dynamics.NAV.Client.exe -Name DumpType -PropertyType "DWORD" -Value 2

#In this example, we will direct the collected dumps to c:\NAVDUMPS folder.
#Check if folder exists, if not – create the folder.
$dumppath = "$env:HOMEDRIVE\NAVDUMPS"
if(!(Test-Path -Path $dumppath))
  {
   new-item $dumppath  –itemtype directory
  }

#Set the dump folder to created folder
New-ItemProperty -Path $keypath\Microsoft.Dynamics.NAV.Client.exe -Name DumpFolder -PropertyType string  -Value "$env:HOMEDRIVE\NAVDUMPS

'Dump collection is now configured. After the problem occurs and application crashes, the dump will be automatically generated in specified folder. The dump and report should be compressed and sent to support.
There are several ways to zip the collected dump. In this example, we will use PowerShell community extensions: http://pscx.codeplex.com
This collection contains number of useful extensions provided by community. Download and install the extensions then import extensions by running this command to load all the modules:
import-module <path to pscx.dll>

#zip the output file and contact support team to provide details
Get-Childitem "$env:HOMEDRIVE\NAVDUMPS" -Recurse | Write-Zip -OutputPath "$env:HOMEDRIVE\NAVDUMPS\ClientDump.zip"

'To disable dump collection once you have collected the data, simply remove the executable key’
remove-item Microsoft.Dynamics.NAV.Client.exe

#and remove collected data
Remove-Item "$env:HOMEDRIVE\NAVDUMPS" -Recurse

 

Best regards

Jasminka Thunes, Escalation Engineer Dynamics NAV EMEA

Lars Lohndorf-Larsen, Escalation Engineer Dynamics NAV EMEA

Bas Graaf, Senior Software Engineer Dynamics NAV

Comments (2)

  1. steven says:

    The instructions don’t match what I find on my Windows 10 pro 64 fully updated machine. If I enter the enable WER command as suggested I get an error message that says windows cannot find Enable-WindowsErrorReporting. God another nightmare from Microsoft.

  2. jthunes says:

    Apologies for late reply, i have not seen this earlier. Some users are not too eager to enable generic collection of problem details, but this can really save some time to everyone. Dumps can also be limited to certain number, so storage limitations can be respected.
    I’m unfortunately unable to get the samme issue as you on Win 10 x64, and my online (and offline) search didn’t return any similar issues, but for now i can suggest to run:

    (Get-Module -Name WindowsErrorReporting ).path

    This should return a path or empty string (if module not found). In case of path, then import the module from the suggested path before proceeding with above instructions. If it returns empty object, then your default path (and env variables) might be a bit different. However, you should be able to find following file on your pc:

    WindowsErrorReporting.psm1

    then import from whichever path it is located at. It is part of WIN 10. If you cannot locate it, please contact us.