Main Site Documentation

SerialPort Missing Reference


#1

Want to define Instance of “SerialPort” in Fez Mini (as show on the back page of Mini datasheet, as follows, has error message: (All other statements appear OK)

.netmf Code in VC# 2008:

using System;
using System.IO;
using System.Text;
using System.Threading;
using System.IO.Ports;
using Microsoft.SPOT;
using GHIElectronics.NETMF.IO;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Hardware.LowLevel;

namespace SerialPortLoopBack
{
public class Program
{
public static void Main()
{
SerialPort UART = new SerialPort(“COM3”, 9600);

etc…

“System” is in the Project’ s References, which in MSDN .NET Framework Class Library states contains
Namespace: System.IO.Ports.SerialPort
Assembly: System (in System.dll).


#2

The SerialPort has moved to another assembly

Try this


using System;
using System.IO;
using System.Text;
using System.Threading;
using System.IO.Ports;
using Microsoft.SPOT;
using GHIElectronics.NETMF.IO;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Hardware.LowLevel;

using System.IO.Ports.SerialPort; //add this 

namespace SerialPortLoopBack
{
public class Program
{
public static void Main()
{
SerialPort UART = new SerialPort("COM3", 9600);


#3

Tnx. What Reference in the new Assembly in, “System”


#4

Still a missing reference for .SerialPort in System.IO.Ports.SerialPort


#5

Did you add the needed assemblies. Adding the “using” statement is not enough. You also need to add the assemblies (the DLLs).


#6

Yes I did.That’s my question: What References and DLLs are required? I already have “System”, i.e. system.dll, which should work accordining to MSDN:

.NET Framework Class Library
SerialPort Class

Represents a serial port resource.

Namespace: System.IO.Ports
Assembly: System (in System.dll).


#7

Look here and let us know if this helps
"What assemblies (libraries) do I need to add to my project?"
http://www.tinyclr.com/faq/


#8

Solved it by paying attention to the FAQ #16!

My missing reference was “Microsoft.SPOT.Hardware.SerialPort”

With this reference, “using System.IO.Ports;” has no missing reference, and the SerialPort instance code is OK.

“using System.IO.Ports.SerialPort; //add this” doesn;t appear to be really needed as it appears to be included in System IO.Ports: