C# showing a form from DLL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mhmani21
    New Member
    • Aug 2007
    • 3

    C# showing a form from DLL

    Hey,
    I'm writting a programm that uses socket programming. I've put all the networking code in one Class library and use all the function like connect and sendmessage and so on from other forms. There is one form I'm having problem with it. Basically, the application recieves compule of strings form the server, writes them to a file, and then calls one form called Solution. While this form is loading, it opens the file and read lines (3 lines) and put each in one textbox. Then there a button to click that is supposed to close this form but not the application (this.hide() or this.close())
    Ive tried having functions in other forms and opening the form from a form other than the DLL. I tried opening it like:
    Solution S = new Solution();
    S.ShowDialog();
    but the problem i'm facing is, when i click on the close button in the Solution form, I get an InvalidOperatio nException error. The error is:
    ............... ............... ............... .........
    System.InvalidO perationExcepti on was unhandled
    Message="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 )."
    ............... ............... ............... .........
    can anyone help me with this?
    Bytheway, Im using C#
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    That sound like the "close" function needs to be called in the same context as the "show" function.
    Like you clicking your button to "close" needs to trigger its way back to the parent who created the object and tell *IT* to close it.
    That seems a little strange, but that was my take on the error message.

    Comment

    • mhmani21
      New Member
      • Aug 2007
      • 3

      #3
      this must work,but the sing is you cant close or hide an open form from another form,or at least i donno how to do it. i did creat an instance and tried to close() function,but this doesnt do it.
      .........
      Originally posted by Plater
      That sound like the "close" function needs to be called in the same context as the "show" function.
      Like you clicking your button to "close" needs to trigger its way back to the parent who created the object and tell *IT* to close it.
      That seems a little strange, but that was my take on the error message.

      Comment

      Working...