[2.0] InvalidOperationException: The Undo operation encountered a context that is different from what was applied in the...

Hi,

I have a Windows.Form application that call a method in a remote object when the user press a button. That application works fine in .Net 1.1 but in 2.0 returns the following error:

"System.InvalidOperationException: The Undo operation encountered a context that is different from what was applied in the corresponding Set operation. The possible cause is that a context was Set on the thread and not reverted(undone)."

And there's no stack trace (VS2005 shows only "External Code").

The latest thing I'v tried was calling a method in the remote object using Invoke and Delegate:

delegate string DelegateType();

static string GetOfferBookStatus() {

OfferBook offerBook = (OfferBook)Activator.GetObject(typeof(OfferBook), "tcp://localhost:8090/OfferBookSubscribe");

return offerBook.GetStatus();

}

private void cmdList2_Click(object sender, System.EventArgs e) {

txtMessages.Text = (string)Invoke(new DelegateType(GetOfferBookStatus));

}

But, doesn't matter if I set a property in a Windows.Form object (like in the example above) or set only a simple string variable: the InvalidOperationException always ocurrs.

Please, any advice !

Alex



Answer this question

[2.0] InvalidOperationException: The Undo operation encountered a context that is different from what was applied in the...

  • mfeigin

    Hi,

    I'm having the same problem; did you find some solution

    thank you,

    Cristiano Muzi



  • norpe

    Hi,

    Again me to tell I've found this thread:

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

    I've tried to remove all Application.DoEvents() calls in my WinForms applications and now I've no more problem with that exception.

    Cristiano Muzi



  • [2.0] InvalidOperationException: The Undo operation encountered a context that is different from what was applied in the...