Click here to Skip to main content
16,016,500 members
Home / Discussions / C#
   

C#

 
Questionvideo capturing and sms feature Pin
4Hamburger27-Aug-07 15:49
4Hamburger27-Aug-07 15:49 
Questioncombobox.datasource question Pin
udikantz27-Aug-07 15:27
udikantz27-Aug-07 15:27 
AnswerRe: combobox.datasource question Pin
mihirhp27-Aug-07 20:28
mihirhp27-Aug-07 20:28 
GeneralRe: combobox.datasource question Pin
udikantz27-Aug-07 21:18
udikantz27-Aug-07 21:18 
GeneralRe: combobox.datasource question Pin
mihirhp27-Aug-07 22:24
mihirhp27-Aug-07 22:24 
QuestionActive Directory Pin
T4AMD27-Aug-07 14:08
T4AMD27-Aug-07 14:08 
AnswerRe: Active Directory Pin
ekynox27-Aug-07 15:52
ekynox27-Aug-07 15:52 
Questionnull exception while passing a serial port instance to an object Pin
murr00727-Aug-07 13:21
murr00727-Aug-07 13:21 
Hello everyone,

I am trying to pass an instance of a serial port to an instance of a class declared in the same scope. When I pass the port in, either by reference or value, I keep getting a null reference exception. The serial port works fine when used outside of the target object, but I can't get it to work from within that object.

Here is what I mean...

private System.IO.Ports.SerialPort serialPort1; //the serial port declared within Form1
private InterfaceCommuncation Communicator; //the object that needs to use the port

//port initialization stuff (abridged)
serialPort1.PortName = "COM1";
serialPort1.BaudRate = 38400;
this.serialPort1.Open(); //this line works fine, no errors
this.serialPort1.Close(); //this line works fine, no errors

//both of these lines cause the same error
//Communicator.initialize(serialPort1);
//Communicator.initialize(this.serialPort1);

******
//This is how the serial port is used in the communicator class
public void initialize(System.IO.Ports.SerialPort sp)
{
sp.Open();
sp.Close();
}

The null reference error occurs inside this function, wether I pass by reference or value. What is the proper way to pass a serial port to another object?


Thanks in advance!

AnswerRe: null exception while passing a serial port instance to an object Pin
Luc Pattyn27-Aug-07 14:41
sitebuilderLuc Pattyn27-Aug-07 14:41 
GeneralRe: null exception while passing a serial port instance to an object Pin
murr00727-Aug-07 15:56
murr00727-Aug-07 15:56 
GeneralRe: null exception while passing a serial port instance to an object Pin
Luc Pattyn27-Aug-07 17:02
sitebuilderLuc Pattyn27-Aug-07 17:02 
QuestionHow can I prohibit writing a characters? Pin
daavena27-Aug-07 10:51
daavena27-Aug-07 10:51 
AnswerRe: How can I prohibit writing a characters? Pin
Pete O'Hanlon27-Aug-07 11:18
mvePete O'Hanlon27-Aug-07 11:18 
GeneralRe: How can I prohibit writing a characters? Pin
daavena27-Aug-07 11:35
daavena27-Aug-07 11:35 
GeneralRe: How can I prohibit writing a characters? Pin
Yitzchok Dev27-Aug-07 12:56
Yitzchok Dev27-Aug-07 12:56 
GeneralRe: How can I prohibit writing a characters? Pin
daavena28-Aug-07 10:28
daavena28-Aug-07 10:28 
QuestionUTF-8 characters in RichTextBox with SelectedRtf... Pin
Paradox2227-Aug-07 10:00
Paradox2227-Aug-07 10:00 
QuestionIUPnPDeviceFinder Pin
MicealG27-Aug-07 9:53
MicealG27-Aug-07 9:53 
AnswerRe: IUPnPDeviceFinder Pin
Mark Churchill27-Aug-07 15:34
Mark Churchill27-Aug-07 15:34 
GeneralRe: IUPnPDeviceFinder Pin
MicealG28-Aug-07 5:38
MicealG28-Aug-07 5:38 
QuestionAdvanced Typed Dataset Pin
hamid_m27-Aug-07 9:42
hamid_m27-Aug-07 9:42 
QuestionSerial Keys. Make trial version. Examples ? Pin
finayev27-Aug-07 9:40
finayev27-Aug-07 9:40 
AnswerRe: Serial Keys. Make trial version. Examples ? Pin
Spacix One27-Aug-07 10:14
Spacix One27-Aug-07 10:14 
QuestionAdding "%" at the end of text in a textbox Pin
basi001427-Aug-07 9:22
basi001427-Aug-07 9:22 
AnswerRe: Adding "%" at the end of text in a textbox Pin
keyboard warrior27-Aug-07 9:24
keyboard warrior27-Aug-07 9:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.