.NET is a high-level framework
and doesn't support direct port access.
My Serial Port FAQ:
.NET 1.0 has no support for legacy ports (COM/LPT).
There are plans to add support for serial ports in a future version:
http://groups.google.com/groups?&selm=O%23vQLn9bCHA.392%40tkmsftngp09
"this sample is very similar to what we will be adding" :
http://www.gotdotnet.com/userarea/filedetails.aspx?FileName=SerialPort.zip
(note, project built with beta VS.NET, read gotdotnet comments)
With 1.0 you have to use PInvoke or Interop :
First understand the Win32 API as described here (C++):
http://msdn.microsoft.com/library/en-us/dnfiles/html/msdn_serial.asp
New MSDN article for .NET (mostly C#):
http://msdn.microsoft.com/msdnmag/issues/02/10/NETSerialComm/
PInvoke samples for C#:
http://www.gotdotnet.com/userarea/filedetails.aspx?FileName=SerialPort.zip
http://msdn.microsoft.com/msdnmag/issues/02/10/NETSerialComm/
or for VB.NET:
http://msdn.microsoft.com/library/en-us/dnvssamp/html/vbcs_usingthecomportinvbnet.asp
My Parallel Port FAQ:
If you have to send raw data to a printer:
HOW TO: Send Raw Data to a Printer by Using Visual C# .NET :
http://support.microsoft.com/?kbid=322091
If you want to control the port pins:
You have to install some kind of hardware drivers!
(Warning: will impact system security/reliability)
for .NET : TSIO (generic IO)
www.thoroughsoft.com
http://65.184.102.81/thoroughsoft/products/Products_TSIO/Products_TSIO.aspx
commercial, specific for printer ports, e.g.:
http://www.zealsoftstudio.com/ntport/download.html
http://www.ntport.com/
For more information about ports, check this sites:
http://www.lvr.com/parport.htm
http://www.beyondlogic.org
My USB Port FAQ:
USB is a hardware bus and as such not directly exposed
to user-mode (Win32) applications (or even .NET).
Only Windows device-drivers do control the USB.
=> get a driver from manufacturer.
So if you connect a printer with USB, use the Win32/.NET printer-API.
Or if you connect a modem with USB, use the Win32 serial-API.
Or if you connect an imaging device (camera/scanner), use TWAIN/WIA.
If you want to design your own external, USB compliant hardware,
you have to understand the USB bus protocol
and implement a controller chip.
Then on Windows side, you have to write your own
device driver with the Windows DDK.
Sure there are OEM kits making all this easier.
Please visit sites like:
http://www.usb.org/
http://www.microsoft.com/hwdev/bus/USB/
http://www.lvr.com/usb.htm
http://www.beyondlogic.org
and learn the technology.