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
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.