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. STAThreadAttribute

STAThreadAttribute

Scheduled Pinned Locked Moved C#
csharpcom
7 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
    asma_panjabi
    wrote on last edited by
    #1

    i am using C#.net 1.1 while using clipboard m geeting this exception System.Threading.ThreadStateException: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. at System.Windows.Forms.Clipboard.GetDataObject()

    C P 2 Replies Last reply
    0
    • A asma_panjabi

      i am using C#.net 1.1 while using clipboard m geeting this exception System.Threading.ThreadStateException: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. at System.Windows.Forms.Clipboard.GetDataObject()

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      // [STAThreadAttribute] [STAThread] public static void Main() put that attribute in your entry point.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      A 1 Reply Last reply
      0
      • C Christian Graus

        // [STAThreadAttribute] [STAThread] public static void Main() put that attribute in your entry point.

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        A Offline
        A Offline
        asma_panjabi
        wrote on last edited by
        #3

        i have made an entry [STAThread] public static void Main() still m getting the exception

        C 1 Reply Last reply
        0
        • A asma_panjabi

          i have made an entry [STAThread] public static void Main() still m getting the exception

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          OK - well, that's how you set it. Do you set the thread model to something else, elsewhere in your code ? I don't even know if you can, but that attribute is what it's telling you to set. Have you googled the error message text ?

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          A 1 Reply Last reply
          0
          • C Christian Graus

            OK - well, that's how you set it. Do you set the thread model to something else, elsewhere in your code ? I don't even know if you can, but that attribute is what it's telling you to set. Have you googled the error message text ?

            Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

            A Offline
            A Offline
            asma_panjabi
            wrote on last edited by
            #5

            Ya i have googled but itz saying to set entry point as what u said. but i cant figure out the exception

            1 Reply Last reply
            0
            • A asma_panjabi

              i am using C#.net 1.1 while using clipboard m geeting this exception System.Threading.ThreadStateException: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. at System.Windows.Forms.Clipboard.GetDataObject()

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              Are you trying to access your object from a background thread?

              Deja View - the feeling that you've seen this post before.

              My blog | My articles

              A 1 Reply Last reply
              0
              • P Pete OHanlon

                Are you trying to access your object from a background thread?

                Deja View - the feeling that you've seen this post before.

                My blog | My articles

                A Offline
                A Offline
                asma_panjabi
                wrote on last edited by
                #7

                M trying to access Clipboard.GetDataObject(); it is throwing exception when accesing clipboard

                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