473,394 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Error with Asynchronic Socket

Hi,
I've a component that use Asynchronic Sockets to comunicate with the server
component. In a Desktop Application, wich use the component, in the main
form open a form in dialog mode and add events handlers to the instance of
the frmMain.MyClientComponent. When i receive events from the component
those are handled and i do this.Invoke to work in the UI Thread. This work
ok until i close the dialog form, when i open the dialog box again when
receive an event and do this.Invoke the next error are raised:
"An unhandled exception of type 'System.InvalidOperationException' occurred
in MyClientComponent.dll
Additional information: Cannot call Invoke or InvokeAsync on a control until
the window handle has been created."

Sorry for my bad english, I hope you can understand me.

And code sample to understand better:
....
MyClientComponent.dll <-- Use Asynchronic Sockets and has ImcomingMessage
event.
....

....//frmMain
MyClientComponent m_ClientComponent = new MyClientComponent();

private void OpenReceiveMessagesForm()
{
frmReceiveMessages ReceiveMessagesForm = new
frmReceiveMessages(m_ClientComponent);
ReceiveMessagesForm.ShowDialog(this);
ReceiveMessagesForm.Dispose();
ReceiveMessagesForm = null;
}
....
....//frmReceiveMessages

MyClientComponent m_ClientComponent
delegate void MessageReceivedEventHandler(IncomingMessageEventAr gs e);

public frmReceiveMessages(MyClientComponent clientComponent)
{
m_ClientComponent = clientComponent;

m_ClientComponent.ImcomingMessage += new
ImcomingMessageEventHandler(m_ClientComponent_Imco mingMessage);
}

private void m_ClientComponent_ImcomingMessage(object sender,
IncomingMessageEventArgs e)
{
try
{
//The first time that is opened this form this method works fine, if i
close this form and re open again, just here fire the error descripted
this.Invoke(new
MessageReceivedEventHandler(m_ClientComponent_Imco mingMessage), new
object[]{e});
}
catch(Exception ex)
{
//An unhandled exception of type 'System.InvalidOperationException'
occurred in MyClientComponent.dll Additional information: Cannot call Invoke
or InvokeAsync on a control until the window handle has been created.
throw ex;
}
}

private void m_ClientComponent_ImcomingMessage(IncomingMessageE ventArgs e)
{
lblMessagesReceived.Text += e.Message + "\r\n";
}

....
Nov 17 '05 #1
0 941

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Rune | last post by:
Hi, I've written a very simple 'kill-server' to help me shut down processes through Telnet or HTTP. The kill-server is a function and is launched as a thread. I use the module socket.py on Python...
0
by: anuradha.k.r | last post by:
hi, i have written a simple socket program in python to connect to a windows machine.On the server side i am running a windows socket program which works perfectly fine,my server program waites at...
2
by: John F Dutcher | last post by:
Can anyone comment on why the code shown in the Python error is in some way incorrect...or is there a problem with Python on my hoster's site ?? The highlites don't seem to show here...but line...
0
by: christian_stengel | last post by:
Hi *, I have just started to learn python and I am having a problem with an python client connecting to a perl server using ssl (I tried this with pyOpenSSL and with the build in SSL Module). ...
3
by: Falk Fassmann | last post by:
Hello people, I have some problem with Debugging in MS Visual C++. I want to generate a TCP/IP-Socket. The compiling-process is fine but when I debugg the project there's occuring some errors...
7
by: | last post by:
Hi all, I have a simple .aspx page running on net 2.0 that is trying to do a http post to a remote server. Here is the code Private Function ProcessRequests(ByVal strbody As String) As String...
0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception { public FtpException(string message) :...
11
by: hazz | last post by:
smtpClient.Send(message) is causing me problems as per specifics in the trace below. Email is sent but not without this error typically upon sending the second email, but sometimes when running...
0
by: Jaap Spies | last post by:
Hi, Running Fedora Core 4: Python 2.4.3 and Python 2.4.1. I'm getting: IOError: (2, 'No such file or directory') all the time. Trying to track down this problem: Python 2.4.1 (#1, May 16...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.