[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now



Posted on 2004-09-24
Medium Priority
Last Modified: 2010-04-15
I have an application that must use the MTAThreadAttribute.  My problem is that it appears that I cannot use the Windows Media Player activex control in a MTAThreaded application.  I keep getting the following error:

An unhandled exception of type 'System.Threading.ThreadStateException' occurred in system.windows.forms.dll

Additional information: Could not instantiate ActiveX control '6bf52a52-394a-11d3-b153-00c04f79faa6' because the current thread is not in a single-threaded apartment.

Is there any way around this problem?????  Does the Media Player control have to be used in a Single Threaded Application???

Question by:gvector1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 10

Expert Comment

ID: 12144605
Why must your application use the MTAThreadAttribute?

Author Comment

ID: 12144711
Because I am writing a media application that is making use of some code written by Idael Cardoso and Ianier Munoz.  The majority of it is a WMF SDK translation that Idael Cardoso wrote in which makes available the Windows Media Format to managed code.  His code can be found here : http://www.codeproject.com/cs/media/ManWMF.asp?select=932380&df=100&forumid=39102&msg=932380
Some of the media code uses multithreading.  Any suggestions?????????

LVL 10

Expert Comment

ID: 12145332
I wonder if your could putting a [STAThread] on your InitializeComponents method of your form would help (or wherever your AxtiveX control is instatntiated).
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 12228125
I am sorry it took so long to get back.  I got caught up on an important project.  I tried using the [STAThread] on the InitializeComponents method fo my for and I still got the same error as above.  Any other suggestions as to how I could approach this problem.

Thanks for the assistance,

Author Comment

ID: 12309670
I found an approach that was suggested to me on the CodeProject Website.  Here is the link

Thanks again,

Accepted Solution

ee_ai_construct earned 0 total points
ID: 12340942
Question answered by asker or dialog valuable.
Closed, 500 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question