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: src/platforms/dotnet/guides/winforms/index.mdx
+164-4Lines changed: 164 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -5,18 +5,178 @@ redirect_from:
5
5
- /platforms/dotnet/winforms/
6
6
---
7
7
8
-
In addition to initializing the SDK with [`SentrySdk.Init`](/platforms/dotnet/), you must also configure the WinForms error handler.
9
-
10
8
Sentry's .NET SDK works with WinForms applications through the [Sentry NuGet package](https://www.nuget.org/packages/Sentry). It works with WinForms apps running on .NET Framework 4.6.1, .NET Core 3.0, or higher.
11
9
12
10
## Configuration
13
11
14
-
The SDK automatically handles AppDomain.UnhandledException. On Windows Forms, for production apps (when no debugger is attached), the small Window pops up when an unhandled error occurs. To get the exception to rethrow the error so it is captured by Sentry, also configure:
12
+
After adding the NuGet package, the SDK should be initialized in the program's main entry point, before launching any forms or performing signifanct work. The options for initialization vary by language.
13
+
14
+
### C# Initialization
15
+
16
+
A C# Windows Forms application will have a `Program.cs` file. You should initialize Sentry in this file.
17
+
18
+
You should also set `Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException)` so Sentry can capture unhandled exceptions.
19
+
20
+
A complete example of the recommended startup is as follows:
15
21
16
22
```csharp
23
+
usingSystem;
17
24
usingSystem.Windows.Forms;
25
+
usingSentry;
26
+
27
+
namespaceWindowsFormsApp1
28
+
{
29
+
staticclassProgram
30
+
{
31
+
/// <summary>
32
+
/// The main entry point for the application.
33
+
/// </summary>
34
+
[STAThread]
35
+
staticvoidMain()
36
+
{
37
+
38
+
// These WinForms options are usually set by default
0 commit comments