Alright, any word on a solution to this. I get the same 'Cross-thread operation not valid:' error. When you use the Application Framework in VB.NET and set a Splash screen, you cannot add an AxWindowsMediaPlayer control to play a video without getting the cross-thread operation error. Is it possible to play a video using a AxWindowsMediaPlayer control on another thread?
It's easy to reproduce. You don't even have to write any code yourself.
Create a VB.NET Windows Forms app.
Add a Splash Screen to the project.
Add a AxWindowsMediaPlayer control to the splash screen.
Open the project properties and make sure 'Enable application framework' is checked.
Set the Splash screen: dropdown to the splash screen you added.
Run the project and you'll get an InvalidOperationException that says "Cross-thread operation not valid: Control 'SplashScreen1' accessed from a thread other than the thread it was created on."
and here is the StackTrace, which is all Framework code, so there seems to be no possible way to fix it:
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
no, i'm not trying to access anything on my own. i didn't write one line of code in this project. i did everything with the designer. the framework itself is trying to access the splash screen from another thread. this only happens when a media player control is on a form that is the splash screen. when using the Application Framework, a splash screen is loaded on a worker thread automatically.
It has something to do with how the Application Framework is trying to get a handle to the splashscreen form to show it before the main form comes up. i can get a handle when there is not a windows media player control on the splashscreen form but an exception is thrown when there is one.