You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/develop/debug-office-add-ins-in-visual-studio.md
+18-14Lines changed: 18 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Debug Office Add-ins in Visual Studio
3
3
description: Use Visual Studio to debug Office Add-ins in the Office desktop client on Windows.
4
-
ms.date: 02/12/2025
4
+
ms.date: 02/19/2025
5
5
ms.localizationpriority: medium
6
6
---
7
7
@@ -14,7 +14,7 @@ This article describes how to debug client-side code in Office Add-ins that are
14
14
15
15
## Review the build and debug properties
16
16
17
-
Before you start debugging, review the properties of each project to confirm that Visual Studio will open the desired Office application and that other build and debug properties are set appropriately.
17
+
Before you start debugging, review the properties of each project in the solution to confirm that Visual Studio will open the desired Office application and that other build and debug properties are set appropriately.
18
18
19
19
### Add-in project properties
20
20
@@ -84,6 +84,9 @@ When Visual Studio builds the project, it performs the following tasks:
84
84
> [!NOTE]
85
85
> If Office uses the Edge Legacy webview control (EdgeHTML) to run add-ins on your Windows computer, Visual Studio may prompt you to add a local network loopback exemption. This is required for the webview control to be able to access the website deployed to the local IIS web server. You can also change this setting anytime in Visual Studio under **Tools** > **Options** > **Office Tools (Web)** > **Web Add-In Debugging**. To find out what webview control is used on your Windows computer, see [Browsers and webview controls used by Office Add-ins](../concepts/browsers-used-by-office-web-add-ins.md).
86
86
87
+
> [!TIP]
88
+
> [!INCLUDE[Identify the webview through the add-in UI](../includes/identify-webview-in-ui.md)]
89
+
87
90
Next, Visual Studio does the following:
88
91
89
92
1. Modifies the [SourceLocation](/javascript/api/manifest/sourcelocation) element of the add-in only manifest file (that was copied to the `_ProjectName_\bin\Debug\OfficeAppManifests` directory) by replacing the `~remoteAppUrl` token with the fully qualified address of the start page (for example, `https://localhost:44302/Home.html`).
@@ -99,7 +102,10 @@ Next, Visual Studio does the following:
99
102
100
103
### Debug the add-in
101
104
102
-
The best method for debugging an add-in in Visual Studio 2022 depends on whether the add-in is running in WebView2, which is the webview control that is associated with Microsoft Edge (Chromium), or an older webview control. To determine which webview control is being used, see [Browsers and webview controls used by Office Add-ins](../concepts/browsers-used-by-office-web-add-ins.md). If your computer is using WebView2, see [Use the built-in Visual Studio debugger to debug on the desktop](#use-the-built-in-visual-studio-debugger-to-debug-on-the-desktop). For any other webview control, see [Use the browser developer tools to debug on the desktop](#use-the-browser-developer-tools-to-debug-on-the-desktop).
105
+
The best method for debugging an add-in in Visual Studio 2022 depends on whether the add-in is running in WebView2, which is the webview control that is associated with Microsoft Edge (Chromium), or an older webview control. If your computer is using WebView2, see [Use the built-in Visual Studio debugger to debug on the desktop](#use-the-built-in-visual-studio-debugger-to-debug-on-the-desktop). For any other webview control, see [Use the browser developer tools to debug on the desktop](#use-the-browser-developer-tools-to-debug-on-the-desktop). To determine which webview control is being used, see [Browsers and webview controls used by Office Add-ins](../concepts/browsers-used-by-office-web-add-ins.md).
106
+
107
+
> [!TIP]
108
+
> [!INCLUDE[Identify the webview through the add-in UI](../includes/identify-webview-in-ui.md)]
103
109
104
110
#### Use the built-in Visual Studio debugger to debug on the desktop
105
111
@@ -117,15 +123,7 @@ The best method for debugging an add-in in Visual Studio 2022 depends on whether
117
123
118
124
1. Follow the steps in the earlier section [Start the add-in project](#start-the-add-in-project).
119
125
120
-
1. Launch the add-in in the Office application if it isn't already open. For example, if it's a task pane add-in, it'll have added a button to the **Home** ribbon (for example, a **Show Taskpane** button). Select the button on the ribbon.
121
-
122
-
> [!NOTE]
123
-
> If your add-in isn't sideloaded by Visual Studio, you can sideload it manually. Follow the instructions to [Sideload an Office Add-in for testing](../testing/test-debug-office-add-ins.md#sideload-an-office-add-in-for-testing) for your platform.
124
-
>
125
-
> In the list of available add-ins, find the **Developer Add-ins** section and select the your add-in to register it.
126
-
127
-
> [!TIP]
128
-
> The task pane may appear blank when it first opens. If so, it should render correctly when you launch the debugging tools in a later step.
126
+
1. Launch the add-in in the Office application if it isn't already open. For example, if it's a task pane add-in, it'll have added a button (for example, a **Show Taskpane** button) to the **Home** ribbon or to a custom ribbon tab that's installed with the add-in. Select the button on the ribbon.
129
127
130
128
1. Open the [personality menu](../design/task-pane-add-ins.md#personality-menu) and then choose **Attach a debugger**. This action opens the debugging tools for the webview control that Office is using to run add-ins on your Windows computer. You can set breakpoints and step through code as described in one of the following articles:
131
129
@@ -186,9 +184,15 @@ Next, Visual Studio does the following:
186
184
187
185
1. Opens the Office application host page of your Microsoft 365 tenancy in Microsoft Edge.
188
186
187
+
> [!TIP]
188
+
> If for any reason, Visual Studio doesn't fully sideload the add-in and none of the fixes earlier works, you can manually sideload it. Follow the steps in [Sideload an add-in to Microsoft 365](../testing/sideload-office-add-ins-for-testing.md#sideload-an-add-in-to-microsoft-365). When you're instructed to browse to the manifest, navigate to the XML file in the folder `_ProjectName_\bin\Debug\OfficeAppManifests` directory.
189
+
189
190
### Debug the add-in on the web
190
191
191
-
The best method for debugging an add-in in Visual Studio 2022 depends on whether the add-in is running in WebView2, which is the webview control that is associated with Microsoft Edge (Chromium), or an older webview control. To determine which webview control is being used, see [Browsers and webview controls used by Office Add-ins](../concepts/browsers-used-by-office-web-add-ins.md). If your computer is using WebView2, see [Use the built-in Visual Studio debugger to debug on the web](#use-the-built-in-visual-studio-debugger-to-debug-on-the-web). For any other webview control, see [Use the browser developer tools to debug on the web](#use-the-browser-developer-tools-to-debug-on-the-web).
192
+
The best method for debugging an add-in in Visual Studio 2022 depends on whether the add-in is running in WebView2, which is the webview control that is associated with Microsoft Edge (Chromium), or an older webview control. If your computer is using WebView2, see [Use the built-in Visual Studio debugger to debug on the web](#use-the-built-in-visual-studio-debugger-to-debug-on-the-web). For any other webview control, see [Use the browser developer tools to debug on the web](#use-the-browser-developer-tools-to-debug-on-the-web). To determine which webview control is being used, see [Browsers and webview controls used by Office Add-ins](../concepts/browsers-used-by-office-web-add-ins.md).
193
+
194
+
> [!TIP]
195
+
> [!INCLUDE[Identify the webview through the add-in UI](../includes/identify-webview-in-ui.md)]
192
196
193
197
#### Use the built-in Visual Studio debugger to debug on the web
194
198
@@ -219,7 +223,7 @@ The best method for debugging an add-in in Visual Studio 2022 depends on whether
219
223
> [!TIP]
220
224
> To debug code that runs in the `Office.initialize` function or an `Office.onReady` function that runs when the add-in opens, set your breakpoints, and then close and reopen the add-in. For more information about these functions, see [Initialize your Office Add-in](../develop/initialize-add-in.md).
221
225
222
-
1. To make changes to your code, first stop the debugging session in Visual Studio and close the Outlook pages. Make your changes, and start a new debugging session.
226
+
1. To make changes to your code, first stop the debugging session in Visual Studio and close the Office on the web page. Make your changes, and start a new debugging session.
0 commit comments