Solved

MTAThread

Posted on 2004-09-24
7
317 Views
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???

Thanks,
Kendal
0
Comment
Question by:gvector1
  • 3
  • 2
7 Comments
 
LVL 10

Expert Comment

by:eternal_21
ID: 12144605
Why must your application use the MTAThreadAttribute?
0
 

Author Comment

by:gvector1
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?????????

Thanks,
Kendal
0
 
LVL 10

Expert Comment

by:eternal_21
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).
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:gvector1
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,
Kendal
0
 

Author Comment

by:gvector1
ID: 12309670
I found an approach that was suggested to me on the CodeProject Website.  Here is the link
http://www.codeproject.com/cs/media/ManWMF.asp?select=932972&forumid=39102&df=100#xx932972xx

Thanks again,
kendal
0
 

Accepted Solution

by:
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
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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