WPF Target Invocation Exception in WindowsBase.dll - wpf

I am working on issue from WPF, which occurs occasionally on client side. Unfortunately, the client is reluctant to provide backup or connection string of his database and I am not allowed to install any external application for diagnosis. So, only thing in my hand is to try to reproduce it. However, I am trying to get solution in parallel from experts on this forum.
At the first look, it seems issue might be due to Scroll Viewer control, as I can see stack trace:
at System.Windows.Controls.ScrollContentPresenter.ValidateInputOffset (Double offset, String parameterName) at System.Windows.Controls.ScrollViewer.
However, at high end, I am getting an unhandled exception as:
System.Reflection.TargetInvocationException occurred in WindowsBase.dll
in my application.
Looking into more details of the error I found exception message as:
Exception has been thrown by the target of an invocation.
Inner Exception shows message:
offset parameter value cannot be Nan.Parameter name: offset. Inner Exception Source is Presentation Framework.
And here is the detailed stack trace from client side:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source,Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at AvocetVM.App.Main()
Does anybody came across this kind of issue Or anybody knows the solution to it?

Related

WPF xaml Designer View Gives System.ComponentModel.Win32Exception

VS2013; full install on Windows 8.1 (upgraded from 8.0)
So the designer can't load any xaml controls what so ever and gives this error. I've reinstalled VS at least 8 times with a full removal of almost all programs on my system.
Ironically a fresh install on a VM of 8.1 (no upgrade) lets VS work just fine and I can view xaml files in the designer.
I've tested this on brand new projects with nothing in them and my existing application as well.
Does anyone know of this error? Google didn't really point me too far. I also have "My Documents" on another drive and the temp folder on C:. Before 2013 and 8.1 everything worked fine in 8.0 and VS2012. I have pasted the error below.
System.ComponentModel.Win32Exception
Invalid window handle
at Microsoft.Expression.DesignHost.Isolation.Remoting.NativeMethods.GetClassName(IntPtr hwnd)
at Microsoft.Expression.DesignHost.Isolation.Remoting.ModalSynchronizer.IsModalWindow(IntPtr hwnd)
at Microsoft.Expression.DesignHost.Isolation.Remoting.ModalSynchronizer.UpdateWindowDisabling(IntPtr hwndActive, IntPtr hwndLastActive)
System.Reflection.TargetInvocationException
Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.UnsafeInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at Microsoft.Expression.DesignHost.Isolation.DesignerProcess.RunApplication()
at Microsoft.Expression.DesignHost.Isolation.DesignerProcess.<>c__DisplayClass2.<Main>b__0()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

WPF Localization with LocBaml: System.IO.IOException was unhandled

I am localizing a WPF application using LocBaml. I have successfully created the satellite assemblies and put them in their appropriate folders. I run the application from my box and it works great! Changing languages on the fly, etc. The problem is, I can't run it on any other machine but mine. I can have a co-worker compile the application on their box and I can successfully run the app from my machine mapped in, but he cannot. It is utterly perplexing. I'm sure it's got to be something so simple I'm overlooking it.
System.IO.IOException was unhandled
HResult=-2146232800
Message=Cannot locate resource 'maincontrol.baml'.
Source=PresentationFramework
StackTrace:
at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at DCG.Designer.Library.MainControl.InitializeComponent() in D:\TFS\CardWizard Software Main\Trunk\ClientInterfaces\DCG.Designer.Library\obj\Debug\MainControl.g.vb:line 628
at DCG.Designer.Library.MainControl..ctor() in D:\TFS\CardWizard Software Main\Trunk\ClientInterfaces\DCG.Designer.Library\MainControl.xaml.vb:line 42
at DCG.Designer.MainWindow.libWindow_LanguageChanged(Object sender, CultureInfo Language) in D:\TFS\CardWizard Software Main\Trunk\ClientInterfaces\DCG.Designer\MainWindow.xaml.vb:line 240
at DCG.Designer.Library.MainControl.Language_Click(Object sender, RoutedEventArgs e) in D:\TFS\CardWizard Software Main\Trunk\ClientInterfaces\DCG.Designer.Library\MainControl.xaml.vb:line 808
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.Controls.MenuItem.InvokeClickAfterRender(Object arg)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run()
at DCG.Designer.Application.Main() in D:\TFS\CardWizard Software Main\Trunk\ClientInterfaces\DCG.Designer\obj\Debug\Application.g.vb:line 65
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Of course, after two days of driving myself crazy it ended up being that I just needed to sign the assemblies. My app was signed with a unique key and therefore my localized assemblies needed to be signed as well. Still doesn't answer the question as to why it worked on my machine unsigned, but anyways, it works now!
Got the answer here: http://social.msdn.microsoft.com/Forums/vstudio/en-US/35d7be1b-a0bb-4388-b05f-70182f0e9018/locbaml-doesnt-work
I signed my new localized assemblies with the following:
sn.exe –R sv-SE\my.resources.dll my.snk

System.InvalidOperationException The calling thread cannot access this object because a different thread owns it

I have a busy indicator that I want to show when my application is doing some computation.
var uiThread = new Thread(() =>
{
autoResetEvent.Set();
bussyWindowVM.Dispatcher = Dispatcher.CurrentDispatcher;
Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
{
var busyWindow = new BusyWindow
{
DataContext = bussyWindowVM,
Owner = Application.Current.MainWindow,
WindowStartupLocation = WindowStartupLocation.CenterOwner
};
busyWindow.Show();
});
Dispatcher.Run();
});
// set single threaded apartment
uiThread.SetApartmentState(ApartmentState.STA);
// mark UI thread as background thread
uiThread.IsBackground = false;
// start the UI thread
uiThread.Start();
// wait until thread exits
autoResetEvent.WaitOne();
But when I run the application it throws
System.InvalidOperationException "{The calling thread cannot access
this object because a different thread owns it.}"
I am not able to figure out how to resolve this problem.
But if I remove Owner = Application.Current.MainWindow then everything works fine but the owner is not set correctly so wen I re-size my application the window doesnot come center of application also It stays on top when I minimize application.
Stack Trace:
at System.Windows.Threading.DispatcherObject.VerifyAccess()
at System.Windows.Application.get_MainWindow()
at MyProject.MyViewModel.<>c__DisplayClass3.<CreateBusyWindow>b__2() in D:\MyStuff\Dev\Repo\MyProject\ViewModels\MyViewModel.cs:line 2482
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at CivilGeo.GeoHECRAS.ViewModels.GeoHECRASViewModel.<>c__DisplayClass3.<CreateBusyWindow>b__1() in D:\MyStuff\Dev\CivilGeoRepo\GeoHECRAS\CivilGeo.GeoHECRAS\ViewModels\GeoHECRASViewModel.cs:line 2492
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Dispatcher.CurrentDispatcher in your background thread creates a brand new Dispatcher for that thread.
This dispatcher cannot access objects from the original UI thread, such as Application.Current.MainWindow.
If you want to run a separate UI thread, you won't be able to set Owner. Also, you shouldn't call BeginInvoke().

WPF - Width and Height must be non-negative

I'm experiencing a strange exception from my application. It has been working well until I upgraded my development machine (same OS + VS2010) and tried to debug the software again. This is the exception I get:
Width and Height must be non-negative.
Stack trace here:
at System.Windows.Size..ctor(Double width, Double height)
at System.Windows.Window.SourceWindowHelper.GetHwndNonClientAreaSizeInMeasureUnits()
at System.Windows.Window.GetHwndNonClientAreaSizeInMeasureUnits()
at System.Windows.Window.MeasureOverrideHelper(Size constraint)
at System.Windows.Window.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(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, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at AdvancedConsole2._0.App.Main() in F:\Projects\hitech\AdvancedConsole2.0\trunk\AdvancedConsole2.0\AdvancedConsole2.0\obj\x86\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
You need to check your width and height. It's a fairly safe bet than one or both of them is negative. I won't say it's a certainty but I'd be willing to bet a lot of money on it :-)
For what it's worth, this may be a problem with a changed monitor resolution. Some people will do a simplistic calculation subtracting your window size from your screen size and dividing by two to center it.
If it turns out your window is larger than your screen, you'll probably get negative values, for either position or size.
Without seeing the code that calculates width and height, this is all conjecture of course. I suggest posting that and/or temporarily adding code to output it somehow so you can see what's going on.
I don't want to take credit for this, but paxdiablo is absolutely right when he suggested a display issue. If I could have commented to support his, I would have, but 50 rep needed.
Here was my issue:
I just recently started using 3 monitors; my laptop and two 22-inch monitors.
To get it to work I had to move the monitors around in the screen resolution page until I had the right order. In doing so, I accidentally moved one monitor to be higher than the others. Visual Studio crashes on the monitor that is not aligned with the other two.
* FIX *
Right-Click on desktop
Select Screen Resolution
Make sure to move the monitor screens so all of them are aligned at
the top.
Apply and Click OK.
And 11 years later, Microsoft released this patch which might possibly fix this issue:
"WPF - Addresses an exception "Height must be non-negative" that can occur when adding items or groups to the collection displayed by an ItemsControl."
See Patch: January 25, 2022-KB5009467 Cumulative Update Preview for .NET Framework 3.5 and 4.8 for Windows 10, version 20H2, Windows Server, version 20H2, Windows 10 Version 21H1, and Windows 10 Version 21H2. Release Date: January 25, 2022, Version: .NET Framework 3.5 and 4.8.

WPF application crashes when going into standby

I have a WPF application. It runs ok, but when the computer goes into "Stand by" mode it crashes, with an unknown exception.
This might have something to do with the fact that my window is transparent.
I am using .NET 3.5 with SP1.
Does anyone have an idea?
Edit 1
When the window is in Visibility.Collapsed - the app doesn't crash.
When the window has no transparency - it also doesn't crash.
This is the stack trace:
System.InvalidOperationException: An unspecified error occurred on the render thread.
at System.Windows.Media.MediaContext.NotifyPartitionIsZombie(Int32 failureCode)
at System.Windows.Media.MediaContext.NotifyChannelMessage()
at System.Windows.Interop.HwndTarget.HandleMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at Widget.App.Main() in C:\Documents and Settings\Lehavi\My Documents\Working Version\Widget\obj\Release\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
at System.Activator.CreateInstance(ActivationContext activationContext)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
In case it is an acess violation or similar unmanaged exception, try to disable all hardware acceleration in your graphic card drivers and see if the problem still occurs. If it doesn't it is a driver issue. The only true unmanaged exception I have seen so far with WPF applications, have been related to to poor drivers.

Resources