.Net CoreAppCenterDevelopmentWPF

App Center and WPF.

First, official introduction: Visual Studio App Center brings together multiple services commonly used by mobile developers into an integrated cloud solution. Developers use App Center to Build, Test, and Distribute applications. Once the app’s deployed, developers monitor the status and usage of the app using the Analytics and Diagnostics services, and engage with users using the Push service.

Second, If you still don’t use it- start using it now! It’s awesome!

Currently, AppCenter supports several OS/platform combinations:

  • iOS // Objective C – Swift, React Native, Cordova, Xamarin, Unity //
  • Android // Java – Kotlin, React Native, Cordova, Xamarin, Unity //
  • Windows // UWP, WPF, WinForms, Unity //
  • macOS // Objective C – Swift //
  • tvOS // Objective C – Swift //

I personally use following services: Distribution, Diagnostics, Analytics and Push – and I am very impressed with the tool.

There are also other services: Build, Test, Auth, Data, etc…

Not long ago, App Center team at Microsoft added support also for WPF. Still in Preview, it’s hot topic, so I will dig in and check how these two players go along.

Application definition on App Center cloud portal

I have valid account on App Center cloud, so all I need to do is to define what type of app I would like to use with App Center. In my case, I just wanna play with Preview version of Windows & WPF.

When my application registration is ready, all I need is app secret key- the key, which defines connection (auth, app id) between my app and App Center. In the next picture I will show how to get this information.

I select my application in App Center, then application Settings and in the top right hand corner menu I select Copy app secret. Secret key in the form of the Guid is copied into my clipboard.

With this information, I am ready to integrate App Center services into my new app.

Integration into application

First, I create new WPF/.NET Core 3.0 project. Then, I add App Center client libraries – in .NET ecosystem this is simple: I just add few NuGet packages.

I install prerelease versions of Microsoft.AppCenter.Analytics and Microsoft.AppCenter.Crashes NuGets.

Then, I register what services my app will use. Basically, for any type of application, the procedure how to integrate AppCenter client services into app is the same: on application start you need to register what services will you use with your app. For example, for WPF type of applications, the correct place is on application “OnStartup” event.

This is basically all I need to do in order to use App Center services in my app. After registration, I can use AppCenter Analytics and Crashes (Diagnostics). I can put in also other services later (e.g. Distribute), but for now I will just focus on these two.

Application Analytics Overview

When I chose to use Analytics, I immediately get basic metrics: active users, sessions, devices, session duration, languages, countries, etc. Very useful information if you want to know who is using your app.

Tracking events

I also want to track user behaviors, e.g. how the end user is using my app. I put trackers on crucial parts of my application. This is very useful service, I can, for example, get matrices on how user uses my app, what parts of application are used the most, what parts are not used at all, etc…

From developer perspective, putting tracking into application is very easy, I just put “markers” on interesting parts of the app, like:

Microsoft.AppCenter.Analytics.Analytics.TrackEvent("CrashAppButton_Click");

Now, I can trace user behavior.

and I can dig even deeper into tracking actions:

Diagnostics (Crashes)

Crashes are automatically send after (or one of the) next application startup. AppCenter handles basically two types of application exceptions: crashes and errors. First case is when app crashes, second when app catches some exceptions, but I still want to have some info about.

Crashes

Let’s take a look at a practical example in my WPF app. I have a button which crashes my application with DivideByZeroException.

And, of course, without wrapping problematic code into try-catch block my app crashes. After next restart, App Center gets crash report.

If debug symbols are available, very nice call stack can be observed in order to fix the issue.

Errors

If I want to catch exception and send report onto AppCenter, I do simply:

Crashes.TrackError(ex);

in catch block, e.g.:

In this case, Error is reported on my App Center, but my app is still rolling.

Conclusion

App Center is awesome tool!

Free tier of App Center is very feature reach. It comes with free services (like Distribution, Analytics and Crash). Super awesome! If you need more services, you can check pricing here.

I use App Center with Xamarin.Forms (android & iOS) and UWP. It’s amazing how easy I get feedback from my apps when shipped into testing channel or in production. I track errors, crashes, versions, countries where app is used, devices on which my app is running, and a lot, lot more.

Based on feedback I polish my app to the maximum. I can trace and fix bugs not found in testing phase, I can analyze how users are using my app, where the users come from, etc…

In my opinion, on the long run, App Center will merge with Azure DevOps, because these two tools overlap on some areas, but in general they complement each other.

What’s your opinion on App Center?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.