Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.".

Posted

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.

Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...