Unhandled Exception in Debugging, Run OK in Starting without Debugging?

When I press "F5" to start Debugging my programe, it gives me some unhandled exceptions, however, when I build"F6" and run the programe without debugging"Shift+F6", it runs OK.

Why it is so?

Is it very important of the Debugging errors?

Thanks!

[301 byte] By [Pockey] at [2007-12-24]
# 1

can you tell us:

  • which version of Visual studio you are using

  • .NET Framework version

  • Does this happen as soon as you press F5?

  • What type of application is it? Console? Winform? ASP.NET?

  • What's the exact error message?

  • ahmedilyas at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# General...
    # 2

    which version of Visual studio you are using
    I am using Visual Studio 2005 Standard Version

    .NET Framework version
    .NET Framework 2.0

    Does this happen as soon as you press F5?
    After I press F5, the application will run, then(after about 3 or 4 seconds) the error will be shown. I should click "Stop Debugging" to end the Debugging. However, it builds successfull and could run without any problems.

    What type of application is it? Console? Winform? ASP.NET?
    It is Winform. A Serial Port Communication GUI.

    What's the exact error message?
    Receive Thread Exception -- > System.InvalidOperationException: Cross-Thread operation not valid: Control 'lcurrent' accessed from a thread other than the thread it was created on.

    So the problem is about cross-thread operation. 'lcurrent' is a Label in my application which will show the current of the board connected to the PC. After I send "AT+ADC?" command to the board, I will receive the string of the current, after a calculation, I will display it on the Label..

    When I run the problem, the current can be shown on the label without problem, however, when I run "Debugging", it shows me the "Cross- thread" error....

    Pockey at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# General...
    # 3

    ok, so you are trying to update a label or a UI component from another thread correct? The correct way of doing this is to invoke the control.

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=564275&SiteID=1

    this is what you would do to interact/update/access a UI Control from a thread which the UI Control was not created from. This is the default behavior now of .NET 2.0 - you must make thread safe calls and the above link should hopefully show you how, with some modifications to the code

    ahmedilyas at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# General...