Debugging
Debugging on the desktop
Code that executes within a module cannot be debugged directly. Code that executes within a dashboard or a persisted browser window - i.e. within a web browser - can be debugged using Microsoft Visual Studio.
Setup
In order to debug UIX dashboards, the following registry keys must be set on the client:
Key: HKEY_CURRENT_USER\Software\Motive\M-Files\<version>\Client\Common\NonVaultSpecifics\ScriptHostIESettings\Main
Value #1: Disable Script Debugger (REG_SZ), set to no
Value #2: DisableScriptDebuggerIE (REG_SZ), set to no
Debugging persistent browser windows
To debug persistent browser windows, you will also need to enable script debugging within Internet Explorer by unticking the Disable script debugging (Internet Explorer)
and Disable script debugging (Other)
within the Internet Explorer advanced settings. If you do not do this then the Attach to Process...
window (detailed in the next section) will not show explorer.exe
.
Debugging dashboards and persistent browser windows
Visual Studio 2010 must be used if your computer runs Internet Explorer 9. If running Internet Explorer 10 or higher, use Visual Studio 2012 or newer.
- Open Microsoft Visual Studio on the machine executing the User Interface Extensbility Framework application.
- Select the
Debug
menu, and chooseAttach to Process...
. - Ensure that
Script code
is selected in theAttach to:
option. - Select the appropriate process.
- If the dashboard was launched by a
ShellUI
module then selectexplorer.exe
. - If the dashboard was launched by a
VaultUI
orVaultCore
module then selectMFStatus.exe
.
- If the dashboard was launched by a
Once the debugger is attached, Visual Studio will allow you to set breakpoints and debug as normal:
Debugging in M-Files Classic Web
User Interface Extensibility Framework applications that target M-Files Classic Web can be debugged within a web browser. This includes module-level code that cannot be debugged on the M-Files Desktop client.
Most modern web browsers have built-in debugging tools, e.g. in Microsoft Edge / Internet Explorer, Google Chrome, Mozilla FireFox, or Safari. This tutorial will focus on the tools available in Microsoft Edge / Internet Explorer, although they are broadly the same in all modern browsers.
- Log into the vault using M-Files Classic Web.
- Open the Developer Tools dialog (e.g. press
F12
). - Click on the
Debugger
tab. - Expand the hostname of the web server (in this screenshot the code is running from
localhost
): - Expand the node for the application (the application
guid
is shown in the node name). - Select the
all
node. The JavaScript forShellUI
modules within the application should be shown in the main window. - Breakpoints and other functionality should now be available within the developer tools.
Once a breakpoint is set, you may need to refresh the page for the correct event to be triggered.
Tips and Tricks
Hiding script errors in persistent browser windows
By default, errors thrown by persistent browser content will be shown within the M-Files client. From M-Files 20.10.9510.0
and higher, errors can be hidden by setting the following setting:
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
"Error Dlg Displayed On Every Error"="no"
This can also be configured within the Internet Options settings: Internet Options | Advanced | Browsing | Display a notification about every script error
.