WPF Splash Screen Win32 exeption when switching to different window while splash screen fades out - by Lars Heinrich

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


10
0
Sign in
to vote
ID 378575 Comments
Status Closed Workarounds
Type Bug Repros 9
Opened 10/30/2008 12:18:43 PM
Access Restriction Public

Description

When switching to an other window while the splash screen fades out i get always get an unhandled win32Exeption. The Stacktrace is:

   bei MS.Win32.UnsafeNativeMethods.SetActiveWindow(HandleRef hWnd)
   bei System.Windows.SplashScreen.Close(TimeSpan fadeoutDuration)
   bei System.Windows.SplashScreen.<Show>b__0(Object splashObj)
   bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   bei System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   bei System.Windows.Threading.DispatcherOperation.InvokeImpl()
   bei System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   bei System.Threading.ExecutionContext.runTryCode(Object userData)
   bei System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   bei System.Windows.Threading.DispatcherOperation.Invoke()
   bei System.Windows.Threading.Dispatcher.ProcessQueue()
   bei System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   bei System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   bei System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
   bei System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   bei MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   bei System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   bei System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   bei System.Windows.Threading.Dispatcher.Run()
   bei System.Windows.Application.RunDispatcher(Object ignore)
   bei System.Windows.Application.RunInternal(Window window)
   bei System.Windows.Application.Run(Window window)
   bei System.Windows.Application.Run()
   bei xxxx.App.Main() in xxx\obj\Debug\App.g.cs:Zeile 0.
   bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   bei System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
   bei System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
   bei System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
Sign in to post a comment.
Posted by Laughing John on 9/14/2010 at 10:08 AM
Is this meant to be closed as Fixed? I'm getting the very same error is VS2010!
Posted by daniel2 on 10/17/2009 at 8:23 PM
Check out http://wpf-daniel.blogspot.com/ for a simple solution
Posted by Joel Poiron on 9/10/2009 at 9:01 AM
This error also happens to me whenever I launch my app and then switch to another app before the splash screen had a chance to close. Fortunately this issue is also very easy to work around.

Here's the code I use:
            
            var appSplash = new SplashScreen("Images/SplashScreen.png");
            appSplash.Show(false);

            //... do some stuff
            
            // Due to a bug in the SplashScreen control, we need to catch exceptions while trying to close it
            try
            {
                appSplash.Close(TimeSpan.FromSeconds(0.3));
            }
            catch
            {
                try
                {
                    appSplash.Close(TimeSpan.Zero);
                }
                catch { }
            }
        }
Posted by Mayank Goyal on 3/28/2009 at 12:19 AM
Yes you can do that easily by using the API's

SplashScreen splashScreen = new SplashScreen("SplashScreen.png");
splashScreen.Show(false);

//Create WPF window or after load of you main window call this

splashScreen.Close(TimeSpan.FromTicks(0));
Posted by John Dunn on 3/27/2009 at 2:00 PM
How does one close the splash screen without the fadeout - is use the API requird? If so, how can I use the API to closely mimic when .NET shows/hides the splash screen?
Posted by Jossef on 2/12/2009 at 3:42 PM
This will get fixed in the next WPF release, the workaround for 3.5 is to not use the fade out. Closing the splash screen with fadeout duration should not hit this.

Thank you. Jossef
Posted by Microsoft on 1/26/2009 at 4:37 PM
Hi. This issue is understood. It's fixed in an upcoming release of the framework.

Thanks for reporting this.
Posted by moadib2k on 1/5/2009 at 9:49 AM
I also get this error, I wrapped the close in a try catch block to swallow the error but the spalsh remains until the application is closed.
Posted by John Dunn on 12/19/2008 at 1:04 PM
I am able to reproduce with my application. I am also not able to create a simple test case which shows the issue.
Posted by Mayank Goyal on 12/1/2008 at 3:51 AM
After a lot of trials, I finally have created a project which throws the error every time without any user interaction. Please download the code from http://cid-849ab30dcb88e658.skydrive.live.com/self.aspx/Public/SplashScreen.zip. Hope you can reproduce the error. This is based on GD_Monkey's comment above.
Posted by Jossef on 11/30/2008 at 12:18 PM
We woudl love to fix this issue, but we cannot repro.
if you have a sample project where this can repro consistently please send us asap

Thank you!
jgoldb@microsoft.com
Posted by Confused_Monkey on 11/17/2008 at 8:20 AM
I can confirm that this is a problem.
My application spawns another process during startup so *always* crashes with this exception.
I have tried catching the exception and setting the Handled flag in Application_DispatcherUnhandledException - this stops the app crashing but leaves the splash screen on-screen until the app closes.
Posted by Lars Heinrich on 11/7/2008 at 11:06 AM
Like goyalmayank I´m also unable to reproduce this in a small app. I´m not allowed to post a video on this. But the video provieded by goyalmayank shows exactly the same problem i´m facing. Often after a reboot the problem is gone. but it comes back after a few hours of working.
Posted by Mayank Goyal on 11/6/2008 at 10:24 PM
I can't seem to create a demo application for replicating the error, though I have recorded a video of the error and shared it on skydrive http://cid-849ab30dcb88e658.skydrive.live.com/self.aspx/Public/Error%20Log.wmv.
Posted by Mayank Goyal on 11/6/2008 at 4:39 AM
The Win32Exception thrown is also there in the Windows XP Professional Edition (English). The exception thrown is
-        Exception    {"The operation completed successfully"}    System.Exception {System.ComponentModel.Win32Exception}

Unfortunately it is not replicable in small applications. This happens every time I change focus from the splashscreen to any other application in my application. I will try and post a sample if at all possible using a dummy application.

Posted by Microsoft on 11/3/2008 at 10:47 PM
Thanks for reporting the issue.

In order to fix the issue, we must first reproduce the issue in our labs. We are unable to reproduce the issue with the steps you provided. We tried to reproduce this issue in Windows Vista (German) with Visual Studio 2008 SP1(English). We tried to repro with the following steps:

1. Create a C# WPF application
2. Drag a png file to WPF project
3. Add buildaction to splashscreen
4. Run the project

It may help if you provide us with:

a) A demo zipped project file
b) A Video file of this issue

It would be greatly appreciated if you could provide us with that information as quickly as possible. If we do not hear back from you within 7 days, we will close this issue.

Thanks again for your efforts and we look forward to hearing from you.

Visual Studio Product Team
Posted by Microsoft on 10/30/2008 at 11:32 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com/)
Posted by Microsoft on 10/30/2008 at 11:32 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com/)