Search code examples
c#compact-frameworknamespaces

C#: how to use Microsoft.Win32.SafeHandles


Why does using Microsoft.Win32.SafeHandles cause the C# Compiler Error:

The type or namespace name 'SafeHandles' does not exist in the namespace 'Microsoft.Win32'

This code is lifted from http://zachsaw.blogspot.com/2010/07/serialport-ioexception-workaround-in-c.html


Solution

  • The problem is that you're trying to use sample code written for the normal .Net Framework in a Compact Framework project. This class is not supported by the CF.