Geeks With Blogs
Josh Reuben
  • Most COM components are STA
  • 2 ways to change the apartment threading model – must be prior to 1st COM object instantiation:
·        Declaratively:
STAThreadAttribute / MTAThreadAttribute – e.g. on Main method
·        Programmatically:
Thread.CurrentThread.TrySetAppartmentState (ApartmentState)
  •  (Try..) avoids InvalidOperationException
  •  CLR creates a COM apartment the 1st time any COM component is used by a managed thread. Once the apartment is initialized, the threading model cannot be changed
 
Posted on Monday, January 24, 2011 10:05 AM | Back to top


Comments on this post: Changing the COM Apartment Model

# re: Changing the COM Apartment Model
Requesting Gravatar...
Nice information. This is a timely information and I learned a lot from this. - Dr. Thomas G. Devlin MD, PhD
Left by Robert Jacob on Dec 28, 2016 2:02 PM

Your comment:
 (will show your gravatar)


Copyright © JoshReuben | Powered by: GeeksWithBlogs.net