Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Ctrl-C with error

Ctrl-C with error

Scheduled Pinned Locked Moved C#
comdata-structuresdebugginghelptutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    A Wegierski
    wrote on last edited by
    #1

    When I click Ctrl-C in my control inherited from TextBox I get following exception (and "c" letter is written to the TextBox): The current thread must set to Single Thread Apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it in ProcessDialogKey() method. Stack trace is: System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy) System.Windows.Forms.Clipboard.SetDataObject(Object data) System.Windows.Forms.DataGrid.ProcessDialogKey(Keys keyData) Any other OLE calls (Ctrl-V etc.) doesn't cause such errors. May be someone know what happens and how to avoid it? Thx in advance Hi, AW

    S I 2 Replies Last reply
    0
    • A A Wegierski

      When I click Ctrl-C in my control inherited from TextBox I get following exception (and "c" letter is written to the TextBox): The current thread must set to Single Thread Apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it in ProcessDialogKey() method. Stack trace is: System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy) System.Windows.Forms.Clipboard.SetDataObject(Object data) System.Windows.Forms.DataGrid.ProcessDialogKey(Keys keyData) Any other OLE calls (Ctrl-V etc.) doesn't cause such errors. May be someone know what happens and how to avoid it? Thx in advance Hi, AW

      S Offline
      S Offline
      sirovsky
      wrote on last edited by
      #2

      By the way, are you sure that you do have [STAThread] on your Main? :)

      A 1 Reply Last reply
      0
      • A A Wegierski

        When I click Ctrl-C in my control inherited from TextBox I get following exception (and "c" letter is written to the TextBox): The current thread must set to Single Thread Apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it in ProcessDialogKey() method. Stack trace is: System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy) System.Windows.Forms.Clipboard.SetDataObject(Object data) System.Windows.Forms.DataGrid.ProcessDialogKey(Keys keyData) Any other OLE calls (Ctrl-V etc.) doesn't cause such errors. May be someone know what happens and how to avoid it? Thx in advance Hi, AW

        I Offline
        I Offline
        Ista
        wrote on last edited by
        #3

        simple put [STAThread] above the Main function try that first I'm not an expert yet, but I play one at work. Yeah and here too.

        1 Reply Last reply
        0
        • S sirovsky

          By the way, are you sure that you do have [STAThread] on your Main? :)

          A Offline
          A Offline
          A Wegierski
          wrote on last edited by
          #4

          Thx, it misteriously disappeared Hi, AW

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups