TLDR; If you need access to Windows specific APIs such as the Event Viewer and the Registry - install the Windows Compatibility Pack nuget package.

The Windows Compatibility Pack

If you need to use APIs from the .NET Framework, such as the EventLog class to log to the Event Viewer or any of the following, then installing the Windows Compatibility Pack nuget package will give you access to these.

  • Code Pages
  • CodeDom
  • Configuration
  • Directory Services
  • Drawing
  • ODBC
  • Permissions
  • Ports
  • Windows Access Control Lists (ACL)
  • Windows Communication Foundation (WCF)
  • Windows Cryptography
  • Windows EventLog
  • Windows Management Instrumentation (WMI)
  • Windows Performance Counters
  • Windows Registry
  • Windows Runtime Caching
  • Windows Services


Be aware though, if you use the APIs from the Windows Compatibility Pack nuget package and then your application some how made it onto a Linux or Mac machine then your app would throw a PlatformNotSupportedException at runtime.

You can guard against this by checking whether you are running on Windows before you use the APIs by calling the System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform() method:

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
    Console.WriteLine("Running on Windows!");
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
    Console.WriteLine("Running on Linux!");
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
    Console.WriteLine("Running on Mac OSX!");

Why Use the Windows Compatibility Pack

If you're planning on moving to .Net Core but plan to stay running on Windows, using the Windows Compatibility Pack is a great first step as you don't have to worry about a PlatformNotSupportedException (though I would still advise wrapping the calling code in a conditional statement - who knows where you're app could end up in 5 years time).

Reasons to Port

  • You want to build highly scalable web apps
  • You may want to run your apps on Linux in the future
  • You want self contained deployments

Reasons not to Port

  • You're building desktop applications (wait for .NET Core 3.0)
  • You're building ASP.NET Web Forms apps
  • You're happy on the .NET Framework!


For a demo of the Windows Compatibility Pack in action, check out the video featuring Microsoft's Immo Landwerth here: