UART - PC Communication Example does not work for me

I am new to this whole .net thing. I followed the instructions from here to install all the software and i did it in order as mentioned.

I then created a new project selecting the FEZ cobra Console Application, as i have the FEZ Cobra board.
I wanted to try the UART so i went to this example for that.
[url]GHI Electronics – Where Hardware Meets Software

when i copy and paste the code in i get the following error.
Error 1 The type or namespace name ‘SerialPort’ could not be found (are you missing a using directive or an assembly reference?)

It does not like this line.

SerialPort UART = new SerialPort(“COM1”, 115200);

On the same page where you started, there is a link to Microsoft’s documentation. From there you can search for SerialPort. I think you can also just put the cursor on SerialPort and hit F1 key.

You need to be here SerialPort Class | Microsoft Learn which tells you what DLL you need and what is the namespace.

SerialPort Class
Represents a serial port resource.
Namespace: System.IO.Ports
Assembly: Microsoft.SPOT.Hardware (in

Thanks GUS, but shouldn’t you guys fix the example ?

What’s wrong with the example?

see first post. It does not work

Fix the example? What is wrong? Mike’s question is valid.

Guys, you can read whats wrong in my first post. I explained it all there.
If you go here
and copy and paste that code example in an new project it will not compile.

Likewise, if i go here:

and copy and paste that code the compiler complains about the same thing.
SerialPort UART = new SerialPort(“COM1”, 115200);

Do i need to install something else ?

Se u later, your missing something.

I just want to check, have you been through the begineers e-book?

When you create a new project, you have to add REFERENCES to the necessary components. That’s totally outside the text you see in an example.

Add references and you might find your problem goes away.

Best bet is to go through the ebook slowly

Sorry guys if i sounded a bit pissy. Like i mentioned i am new to this .net embedded.
I am just so overwhelmed at what all it seems it can do, its insane. Then when i tried to do something simple like print out to the URAT i was getting nothing but problems.
I just started to read the beginners e-book when i got your post. I will take my time and read through the whole thing. Hopefully by the time i get to the end i will have calmed down and have a better grip on the whole concept.

Thanks guys for helping the insane newbe

ok, got it working now.
Coming from a C background and looking at the beginners guide example on the uart, it seems there is no printf statement. How do you guys deal with formatting of a variable.
unsigned float z = 23.2;
printf(“Value =%4.2f\r\n”);


unsigned int hours,second, minutes;

hours = 12;
minutes = 5;
seconds = 23;

printf(“Time: %02u:%02u:%02u\r\n”);

will printf formatted “Time: 12:05:23”

Those are 2 complete different questions. C# is same on our devices and on PCs so a quick search of the web should help a lot. For example, you need DateTime object instead of variables. This will make everything much easier.

Please start new threads with new questions.