In our last two posts in this Ozcode onboarding series, we went through the steps of getting started with Ozcode on Windows IIS and an Azure Application Service. As two different ways to deploy a SaaS service, both deployment options present similar challenges for Production debugging. But what do you do when you don’t even have access to your Production environment? That’s the case when your product is a desktop application. Your executable may be throwing exceptions on your customers’ desktops, and you wouldn’t even know it. Even if your users report an issue, it’s usually somewhere between hard to impossible to reproduce it and understand what they’re experiencing. Also, reproducing the error usually requires the user’s data and that often includes sensitive information that your customers can’t share with you. In this post, we’ll go through the steps of setting up Ozcode to debug WPF Desktop applications, and as in the other cases, there are three basic steps:
- Step 1. Create or sign in to your account
- Step 2. Create your application on Ozcode Production Debugger
- Step 3. Download and run the Ozcode Windows installer on your desktop or infrastructure and follow the cues
Once the Ozcode agent is installed on the desktop and connects to your application, you can start debugging. The agent runs alongside the application. When an exception is thrown, it autonomously captures the error execution flow and transmits telemetry data to the Ozcode Server. You can now log on to the Ozcode Dashboard and see all the exceptions captured. At the end of this post, I’ll touch on how Ozcode’s time-travel debugging helps you find the root cause of exceptions.
Step 1: Creating or signing in to your account
To create or sign in to your account, just browse to https://app.oz-code.com/sign-in and follow the simple instructions. Nothing difficult here. If you’re signing up for the first time, you’ll get an email confirmation message with a link that puts you right where you need to be.
Step 2: Creating your application on Ozcode Production Debugger
Once you’re signed in, you can create your first application. Give your application a name and click Create. When Ozcode creates the application, the server generates an application token, which you will need to provide to the WPF installer later on. The Copy button next to your token will come in handy at that time. You can now select the options for a WPF deployment which is:
My Host --> Windows --> Desktop (WPF & WinForms)
Ozcode will display the full installation instructions.
Step 3 Download and run the Ozcode installer on your desktop
The Desktop installation instructions point you to installation instructions that are common for both Desktop and IIS installation pools. The first thing you will do there is to download the installer. Run the installer making sure to follow these important steps:
- Only select Attach to desktop applications to install the WPF and other desktop application bindings.
- Select the executable to be monitored
- Remember that Copy button I mentioned when you created your application in the Ozcode server? Now’s the time to use it to copy your application token and paste it in the installation wizard.
Once the agent is installed, it will start capturing exceptions, and the server will indicate that the agent is up and running. On desktop applications (WPF and WinForms), the Ozcode agent uses your logging framework to track exceptions. If you are using any of the standard .NET logging frameworks such as Serilog, NLog, or others, Ozcode detects any calls to Logger.Error or Logger.Fatal and records the time-travel debug information for the error execution flow of that exception. Watch this screencast to see the whole process from start to finish: https://youtu.be/sQ6QI_zbXIY
Your customers aren’t as technical as you’d like them to be
Installing the Ozcode agent is easy for your technical team, both in Development and QA, but you can’t always count on your customers having the wherewithal (or the desire) to run a separate installation of the Ozcode agent. To make it easy on your customers (which will later translate to “easy on yourself”), you can include the Ozcode agent installation as part of your application’s installation wizard, or just run a silent installation of Ozcode. If this is where you’re headed, talk to us. Now you’re ready to go with WPF debugging.
Debugging an exception
Ozcode takes a three-phased approach to debugging an exception: capturing, captured, and fully captured.
Once the Ozcode agent is up and running alongside your desktop application, it automatically starts monitoring your application for exceptions. The first time an exception is thrown, Ozcode captures it and adds lightweight instrumentation along the error execution flow of your code. This is the “Capturing” phase. You’ll see the exception in the Ozcode dashboard, and you’ll even see the stack trace, but you’ll have to wait for the next phase to really start debugging.
The second time an exception is thrown, the Ozcode agent’s instrumentation is already in place to add what we call primary debug information. The recorded error execution flow is now referred to as a “lightweight” capture that provides the complete call stack and variables where the exception was thrown. This is often enough to understand what happened.
Fully captured phase
If a lightweight capture does not provide enough information, you can select a “Full Capture,” which tells the Ozcode agent to add additional instrumentation so that next time the exception is thrown, you will get full time-travel debug information which you can use to debug the exception. This is the “Fully captured” phase. Time-travel debugging should look familiar to you since it’s very similar to your experience when debugging your development code in your IDE. Here’s what it looks like: https://youtu.be/dMPAvgIjJ_0
When QA Must Debug WPF Applications on the Desktop
Reproducing a bug can be difficult, even if it happens on a QA desktop machine, and this problem is the root cause of the “But it works on my machine” conflict between Dev and QA. It’s one of QA’s worst nightmares. But using Ozcode puts all that to rest. With the Ozcode agent installed alongside the application that QA is testing, any exception is automatically captured along with the complete error execution flow. Moreover, Ozcode will even recognize if the error has happened before, so you don’t have to triage it over and over again. Once Ozcode has captured the error, handing it over to Development to fix is easy. Our trusty QA engineer just shares a link to the exception capture with Dev who then has all the information needed for a fix. This is what you call a perfect bug report. No arguments, no discussion, just hitting the nail right on the head. Stay tuned for the next posts in this series, where we’ll cover how to set up Ozcode for Docker, Azure Functions, and Service Fabric.
Ozcode Production Debugger
Automonous exception capture
Don’t chase after exceptions. They automatically appear in your dashboard.
Get insights into your code down to the deepest levels.
View the true state of your code anywhere in the execution flow of an error.