开发者

Mysterious InvalidOperationException

What does mean with type of exception?

"The Undo operation encountered a context that is different from what was applied in the corresponding Set operation."

I spent over 5 hours trying to find where exception arises((

update

Sorry for the开发者_JS百科 misinformation..i found mistake..but can't figure out how that happens

In main thread created worker thread that create new form and calls form.showDialog.. After calling form.Close application dies:((


An exception is a kind of message sent to informs that something bad has happened. It usually has extra information about the bad situation.

It's like a bubble coming from under the water to surface. If nobody catch it, then it is shown to you (here the name is unhandled exception).

You should avoid unhandled exceptions in your code and think about all bad situations and do something for them. For example if your program is gonna write something on a CD and there's no CD in the CD-ROM, you should show a message to the user and tell him to put a CD in the CD-ROM. This would be something like this in your code:

try
{
    // Copy file to CD
    // Show message: File Copied successfully
}
catch (Exception ex)
{
    // Something wrong happened: there's no CD in CD-ROM, CD has not enough space...
    // Show message: Cannot copy file!
}

In the above example ex is of type of Exception and has some details about the bad situation. As you see After the line // Copy file to CD I try to show a success message to the user. This is because as soon as we fail at the line // Copy file to CD program will resume from catch part, because we have got the bad situation and have some information about it. If you don't use try/catch in the above example, and use it in another code, the you have the chance to get the exception there before it becomes an unhandled exception.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜