Hmm, I've changed it to the full name
void CzebraDlg::OnBnClickedButton5()
{
//SerialPort *mySerialPort = gcnew SerialPort("COM4");
System.IO.Ports.SerialPort ^mySerialPort = gcnew System.IO.Ports.SerialPort("COM4");
try
{
if (mySerialPort->IsOpen)
{
mySerialPort->Close();
}
//mySerialPort->PortName = "COM4"// + IDC_EDIT2->Text;
mySerialPort->Open();
}
catch (Exception ^ex)
{
CerrorDlg cid; //*** Create an instance of our dialog
cid.DoModal(); //Display Dialog box
}
}
But now the errors are different,
[glow]1>.\zebraDlg.cpp(1693) : error C2882: 'System' : illegal use of namespace identifier in expression
1>.\zebraDlg.cpp(1693) : error C2228: left of '.IO' must have class/struct/union
1>.\zebraDlg.cpp(1693) : error C2228: left of '.Ports' must have class/struct/union
1>.\zebraDlg.cpp(1693) : error C2228: left of '.SerialPort' must have class/struct/union
1>.\zebraDlg.cpp(1693) : error C2065: 'mySerialPort' : undeclared identifier
1>.\zebraDlg.cpp(1693) : error C2061: syntax error : identifier 'System'[/glow]
1>.\zebraDlg.cpp(1698) : error C2227: left of '->IsOpen' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>.\zebraDlg.cpp(1700) : error C2227: left of '->Close' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>.\zebraDlg.cpp(1703) : error C2227: left of '->Open' must point to class/struct/union/generic type
1> type is ''unknown-type''
Maybe I missed using a namespace? Here are the ones I'm using
#using <System.dll>
#include "stdafx.h"
#include "zebra.h"
#include "zebraDlg.h"
#include <string>
#include <fstream>
#include "windows.h"
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include "usb.h"
#include <setupapi.h>
#include <hidsdi.h>
using namespace System;
using namespace System::IO;
using namespace System::Threading;