.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Serial Comm: Use P/Invoke to Develop a .NET Base Class Library for Serial Device Communications

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

Out-of-the-box, the only way of coding RS232 serial communications applications in the .NET environment is to import the outdated and somewhat limited MSComm ActiveX control. This article describes the development of a lean, multithreaded, and modern RS232 base class library in C# managed code. The library uses Platform Invocation Services to interact with the Win32 API directly. Application programmers can use the library from any .NET language through inheritance; the article explores examples written in C# and Visual Basic .NET.

John Hind

MSDN Magazine October 2002

View Complete Post

More Related Resource Links

FAQ: How do I use the SerialPort Class for simple serial communications?

How do I use the SerialPort Class for simple serial communications?Please remember to mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

CLR Inside Out: What's New in the .NET Framework 4 Base Class Library


Just about everyone who uses Microsoft .NET uses the Base Class Libraries (BCL).When we make the BCL better, almost every managed developer benefits. This column will focus on the new additions to the BCL in .NET 4 beta 1.

Justin Van Patten

MSDN Magazine September 2009

CLR Inside Out: Base Class Library Performance Tips and Tricks


The common language runtime (CLR) sits at the very heart of managed code. Indeed, it is the heart of managed code, so to understand managed code you need to understand the CLR.

Kit George

MSDN Magazine January 2006

Base Class Library FAQ


There's already a BCL FAQ on MSDN,


This document is a supplement to the FAQ.

1.     How do I compare two DateTime objects?

Full duplex pc to half duplex serial communication with SerialPort class in C++ (but any language wi


Hello.  I am a bit new to the .NET environment, and though I feel I was able to get a good handle on most of the basics of .NET, I believe I've encountered a problem beyond the basics.  I am trying to talk with a device called a ColorPAL that uses asynchronous serial communication, but it is half-duplex instead of full-duplex.  I am able to send it the hex string commands that it wants just fine with the TX line.  However, I find myself unable to read because the RX isn't connected to anything.  Basically what I want to do is that I want to be able to swap the TX line to become a RX line so that I can then read line of the half-duplex.  I read that there is a PinChanged event, so it lead me to believe there is a way to change pins??   If the RX line is very high impedance I could connect it to the TX line, but I have no idea about that.


How can I get a full duplex to read a half-duplex using the visual studio software?


Here is the code I'm using, in case that helps.

#include "stdafx.h"
#include <Windows.h>

using namespace System;
using namespace 

Serial Communication with the .NET Compact Framework

Learn how to make your applications communicate over a serial port and how to handle common issues when implementing serial solutions. After a general discussion about serial communication and a common serial communication standard, this article demonstrates a practical use of the technologies through sample source code written in C#.

bluetooth print via serial port PDA

Print via BlueTooth using PDA

Serial Port Communication Read and Write using C#.net

In this simple article you will learn that how you can Open and read COM port data using System.IO.Ports Namespace.
Simply just create New Project of windows application in C#.

Import ServiceProcess APIs
using System.IO.Ports

Imports System.IO.Ports

Write Parsing functions which parse port data according to attached device

How to change the default page base class?


I've tried setting the <pages pageBaseType="DynamicWebPage" /> value in web.config, but when I response.write out the page type, I'm still getting Microsoft.WebPages.WebPage.

I'm simply trying to sub-class WebPage and add some additional functionality such as a dynamic PageData dictionary similar to Phil Haack's dynamic ViewData dictionary.



Can I replace the EntityObject as base-class in Entity Designer 3.5 sp1?


I'm using EF3.5sp1 for a project, and I've been working around many of its problems... as such, my entity partial classes have a lot of logic in them for change-tracking and whatnot.  Obviously, I'd like to factor this logic out into a common base class, but of course all my objects must derive from EntityObject.  Is it possible to tell them to derive from some class of my own invention (which would actually likely derive from EntityObject themselves)?

I'd rather avoid editing the EDMX file unless the changes will be safe on entity-model-update, since I'm still making changes to the database schema in this early state of my project.


Also, is there any good workaround for the fact that the change isn't tracked when you change EntityReference.EntityKey?

Using a GenericHandler as a WebResource inside a Class Library



I hope this is the right place to ask this question.

I'm trying to make a control class library. I want to have a GenericHandler as a WebResource so I could call it from the web project that will use that control.

I need this handler will get parameters from the query string and return JSON data acourding to what it get in the QS.

I know how to create JS and images WebResources, so I tried the same on a generic handler I added to the class library project but all it does is return the source of the handler file and not the result.


Is what I'm trying to do possible? If so, what should I do?


Thank :-)

Localization not working in class library (composite control)



I have a class library called WEM.portal which used Resource files to localise text in my composite controls.

I store my resource files (eg MyResourceFile1.resx) in App_GlobalResources folder and then refer to them using

MyLabel1.text = My.Resources.MyResourceFile1.MyResourceKey1

This is all working ok until I create seperate files for each language such as MyResourceFile1.FR-fr.resx.

I have implemented this throughout my other web applications but the Class Library doesnt seem to want to work the same way

When I load the page it correctly showes the resourced keys which I have done through the web application BUT the resource keys in the composite controls does not seem to pick up the culture code.

Am I missing something stupid. Ive tried

  • changing the Build Action on the resource file to Content and Custom tool to GlobalResourceProxyGenerator
  • Creating a resourceManager but to no avail


Robotics: Writing and Testing VPL Services for Serial Communication


VPL, part of Robotics Developer Studio is intended for novice programmers, but is also useful for testing and prototyping. We write a simple serial port service that allows you to send and receive data.

Trevor Taylor

MSDN Magazine February 2010

Timers: Comparing the Timer Classes in the .NET Framework Class Library


Timers often play an important role in both client applications and server-based components (including Windows services). Writing effective timer-driven managed code requires a clear understanding of program flow and the subtleties of the .NET threading model. The .NET Framework Class Library provides three different timer classes: System.Windows.Forms.Timer, System.Timers.Timer, and System.Threading.Timer. Each of these classes has been designed and optimized for use in different situations. This article examines the three timer classes and helps you gain an understanding of how and when each class should be used.

Alex Calvo

MSDN Magazine February 2004

Serial approval workflow keeps running


I have a serial approval workflow created out of the box. The setting cancell this workflow when the document is rejected is selected. But if one of the approvers rejects it the workflow keeps running. After this is it will give acces denied errors for the other approvers.

So for example what is happening. The workflow is started and sends a email to persone 1. This persone approves so the workflow sends a email to persone 2. Persone 2 decided to reject the document. Now i want the workflow to be cancelled, but it keep running and sends a email to persone 3 for approval. If persone 3 opens the workflow he get's a acces denied error, i guess because of the reject.

Anyone has a idea what is happening here?

Web Service and Base Class Sub Routines



I have several Web Services that I call using jQuery, they are all <WebMethod()> _    Public Function and return either a boolean or string, depending on the function.

I have some Web Service functions, where I would like to call sub routines I have in my base class, they are Public Sub's.

When I add a call of a sub routine in the Web Service function, I get a blue line that says 'Object reference not set to an instance of an object'.  If I change the sub routine to Public Shared Sub, then the blue line and error go away, but I get other errors from the calls I was successfully making to the base class routines before.

Is there a way to get these two to work together?

"The base class includes the field 'WebUserControl1', but its type (common_WebUserControl) is not


I tried to convert a project from ASP.NET 1.1 to 2.0 and found one big problem which stops the whole process.

An .aspx page from the subfolder "admin" includes a user control from the subfolder "common". Both subfolders ("admin" and "common" are in the root).

- admin
-- aspx page
- common
-- user control

The page works well when started from Visual Studio, but when the project is precompiled for deployment, the next error occurs:

"The base class includes the field 'WebUserControl1', but its type (common_WebUserControl) is not compatible with the type of control (ASP.common_webusercontrol_ascx)"

I tried to use "Reference" in the .aspx page, but that doesn't work.

Does anybody know any workaround for this?
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend