JumpyNET Posted June 7, 2005 Posted June 7, 2005 I have an application which detects if an instance of it is allready running. And if so it will SendMessage(WM_SETTEXT) to the first instance's TextBox called communicator. This works correctly! But the problem is that I get an error in the TextChanged event: private void Communicator_TextChanged(object sender, EventArgs e) { String msg = Communicator.Text ; //MessageBox.Show(this,msg); ActiveForm.Text = msg; } The MessageBox (commented out) will show correctly but why doesn't it work without "this"? The real problem is "ActiveForm.Text = msg;", which causes the following error: "Object reference not set to an instance of an object.". Quote
Machaira Posted June 7, 2005 Posted June 7, 2005 What's the Call Stack look like when it hits this line? Are you in the middle of destroying the ActiveForm? Quote Here's what I'm up to.
JumpyNET Posted June 7, 2005 Author Posted June 7, 2005 Call Stack What's the Call Stack look like when it hits this line? Are you in the middle of destroying the ActiveForm? Like this. I'm destroying the instance that sent the message but not the one receiving it. Quote
Machaira Posted June 8, 2005 Posted June 8, 2005 I'm assuming the exception is occurring in the second instance. How are you sending the message to the first instance? Quote Here's what I'm up to.
JumpyNET Posted June 8, 2005 Author Posted June 8, 2005 I'm assuming the exception is occurring in the second instance. How are you sending the message to the first instance? SendMessage(ComHandle, WM_SETTEXT, 256, "Teksti"); ComHandle is read from a static place in windows registry were the first instance will save it's Communicator.Handle. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.