ianinspain
asked on
“A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll COM" problem en my COM event in c#
Hi there,
can anyone help? problem doesn't exist in vs2003 only in vs2005 BUT i have half fixed it....
Basically an event arrives in c# from my COM activeX ... when it arrives it appears to be in a different thread... well i think that is what the error msg means.... Hence i wrote a delegate and a method to do the writing for me.
If i put a breakpoint on the Eventhandler before the { , and when it enters ... continue and take off break point it appears not to be in a different thread
If i don't put a breakpoint the good news is i got it working ... it prints the data to the textbox BUT errror msg is still displayed in the output window..
Am i a missing something??
Thanks in advance
Ian
public delegate void WriteToLogCallback(string text); //this is a delegate to do the job
private void myConnection_Data(int hotlink) // is an event that arrives from my COM dll
{
Data myData = (Data)myChannel[0].getData ();
txtNum.Invoke(new WriteToLogCallback(this.Wr iteToLog), new object[]{myData.num});
//txtNum.Text = myData.num; // This line used to give errro message and not event write to the text box!!
Etc
.
.
private void WriteToLog(string text)
{
// Set the textbox text.
txtNum.Text = text; /// Ok it now prints the details to the screen in txtbox but the error msg is still displayed
//A first chance exception of type 'System.InvalidOperationEx ception' occurred in System.Windows.Forms.dll COM
}
can anyone help? problem doesn't exist in vs2003 only in vs2005 BUT i have half fixed it....
Basically an event arrives in c# from my COM activeX ... when it arrives it appears to be in a different thread... well i think that is what the error msg means.... Hence i wrote a delegate and a method to do the writing for me.
If i put a breakpoint on the Eventhandler before the { , and when it enters ... continue and take off break point it appears not to be in a different thread
If i don't put a breakpoint the good news is i got it working ... it prints the data to the textbox BUT errror msg is still displayed in the output window..
Am i a missing something??
Thanks in advance
Ian
public delegate void WriteToLogCallback(string text); //this is a delegate to do the job
private void myConnection_Data(int hotlink) // is an event that arrives from my COM dll
{
Data myData = (Data)myChannel[0].getData
txtNum.Invoke(new WriteToLogCallback(this.Wr
//txtNum.Text = myData.num; // This line used to give errro message and not event write to the text box!!
Etc
.
.
private void WriteToLog(string text)
{
// Set the textbox text.
txtNum.Text = text; /// Ok it now prints the details to the screen in txtbox but the error msg is still displayed
//A first chance exception of type 'System.InvalidOperationEx
}
ASKER
only the output window
ASKER
it appears as soon as i attempt to write anything to the screen ... in the case before i used the delegate ... it was in the event... but it wouldn't write anything to the screen.... now i use a delegate.. the msg occurs also in the delegate method as soon as i attempt to write to the screen .... but at least this time it actually writes something..
Ian
Ian
ASKER
heres the actually msg straight from the output window.... it doesn't give me a exception dialog though..
A first chance exception of type 'System.AccessViolationExc eption' occurred in GetRealTime.exe
and now i am doing
this.Invoke............
A first chance exception of type 'System.AccessViolationExc
and now i am doing
this.Invoke............
"First chance exception" message means: exception was thrown somewhere, but was catched and successfully handled. If this doesn't happen in your code, this can be in some .NET libraries. You can ignore this message.
ASKER
hi thanks.. are you saying it isn't important then?
thanks
ian
thanks
ian
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
this->Invoke(new WriteToLogCallback(this.Wr
Where does "first chance exception" message appear? In Output window or you have exception dialog?