I have a WPF application that fails to come out of the timed sleep, followed by hibernate.
The render thread seems to be failing during initialization. I tried removing hardware acceleration to check that it's not graphics card related, but that did not help.
Here is an exception along with the stacktrace:
ERROR An unspecified error occurred on the render thread.
Stack trace: 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()
I googled around, and people suggest that it might have something to do with AllowsTransparency property being set to true; however, i did not see this issue when running a simple test app.
Any ideas about the exception and possible causes/solutions are highly appreciated.
Try this:
967634 FIX: You may experience several issues when you render graphics by using Windows Presentation Foundation (WPF) in an application
967634
Note: Unfortunately, you'll probably have to call. However, it's free even if they charge you at first, they will refund your money if all you do is ask them for the fix.
Related
EDIT: This happens because the dockable panel is semi-transparent when it's moved to floating. The fix was to disable transparency.
I use a custom panel-feature (3rd party, non-public NuGet) that has visual-studio like dockable panels. If I float a panel and resize it (couple of times) on Citrix XenApp it crashes. With following stack in log file (only few lines).
Unhandled exception. System.Runtime.InteropServices.COMException (0x88980406): UCEERR_RENDERTHREADFAILURE (Exception from HRESULT: 0x88980406)
at System.Windows.Media.Composition.DUCE.Channel.SyncFlush()
at System.Windows.Media.MediaContext.CompleteRender()
at System.Windows.Interop.HwndTarget.OnResize()
at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage 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, Int32 numArgs)
It does not happen when I run it in any environment except Citrix. And it can be reproduced in all customer environments with same Citrix version. This was not reproducable with older version of Citrix XenApp but it's not possible to ask customers to downgrade.
This happens with Citrix version 7.6 on 2012 R2. Seems to happen on all 7.6 and one 7.9 installations.
Does not happen on 6.5 on 2008 R2.
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?
I am using sqlite database instead of sql server 2008 in my WPF project.
I am using Entity Framwork for performing CRUD operations.
Work perfectly fine in my machine.
But when I published and ran on other machine application doesn't work
The problem is that the application tries to connect to the database which doesn't exist on that machine.
<add name="PersonalExpenseDBEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SQLite;provider connection string="data source=E:\sqlLite\db\PersonalExpenseDB.s3db"" providerName="System.Data.EntityClient" />
As you can see datasource is referring to database file
data source=E:\sqlLite\db\PersonalExpenseDB.s3db
which was present on my machine but isn't on other machine.
So, naturally it doesn't find the database file on other machine and gives me error
My question is: How to make the database local to the application? i.e. when i publish the app, database file should be copied and made local to the application.
The error i get is
System.Data.EntityException: The underlying provider failed on Open. ---> System.Data.SQLite.SQLiteException: Unable to open the database file at System.Data.SQLite.SQLite3.Open(String strFilename, SQLiteOpenFlagsEnum flags, Int32 maxPoolSize, Boolean usePool) at System.Data.SQLite.SQLiteConnection.Open() at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) --- End of inner exception stack trace --- at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) at System.Data.EntityClient.EntityConnection.Open() at System.Data.Objects.ObjectContext.EnsureConnection() at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) at System.Data.Objects.ObjectQuery`1.Execute(MergeOption mergeOption) at SqlLiteDatabase.List.Window_Loaded(Object sender, RoutedEventArgs e) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent) at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root) at MS.Internal.LoadedOrUnloadedOperation.DoWork() at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks() 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.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget) at System.Windows.Interop.HwndTarget.OnResize() at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage 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, 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.ShowWindow(HandleRef hWnd, Int32 nCmdShow) at System.Windows.Window.ShowHelper(Object booleanBox) at System.Windows.Window.Show() at System.Windows.Window.ShowDialog() at SqlLiteDatabase.MainWindow.button1_Click(Object sender, RoutedEventArgs e)
When I use the mouse wheel to scroll the WPF Toolkit DataGrid on a Vista 64 Machine I get a cryptic low level error:
at System.IntPtr.op_Explicit(IntPtr value)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(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)
I logged an issue on CodePlex.
But has anyone found a way to resolve this already?
I just run into this issue myself.
Not sure if it is still usefull to you but here is the fix I found in case anyone else needs it as well.
I found this thread in the OpenTK project that smelled a lot like the problem I was having for a WPF project in a vista 64 machine. Like explained in that thread, the problem seems to be a misshandled sing bit on the wParam of the MouseWheel message. The Overflow exception happens in the HwndMouseInputProvider call when it tries to cast the wParam IntPtr to an int.
So the workaround is adding a hook to filter windows messages on the main window. The hook callback checks the value of wparam for the WM_MOUSEWHEEL message. If the value overflows then the value shifter around to recover the right bit information, the current message is marked as handled, and a new message is posted with the new value.
public partial class Window1 : Window
{
private const int WM_MOUSEWHEEL = 0x020A;
public Window1()
{
InitializeComponent();
SourceInitialized += (o, e) =>
{
HwndSource source = PresentationSource.FromVisual(this) as HwndSource;
source.AddHook(WndProc);
};
}
[DllImport("user32.dll")]
private static extern IntPtr PostMessage(IntPtr hwnd, IntPtr msg, IntPtr wParam, IntPtr lParam);
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
switch (msg)
{
case WM_MOUSEWHEEL:
// Check that wParam won't cause an OverflowException
if ((long)wParam >= (long)Int32.MaxValue)
{
// Filter the evenet
handled = true;
HwndSource source = PresentationSource.FromVisual(this) as HwndSource;
// Repost the event with the proper value
PostMessage(source.Handle, new IntPtr(msg), new IntPtr((long)wParam << 32 >> 32), lParam);
}
break;
}
return IntPtr.Zero;
}
This works well for me. If anyone can add or correct anything would be great!
K
This bug is within Microsoft's libraries and it is unbelievable that its still there.
To circumvent it presuming you have Visual Studio and you are the developer:
Right click on the project and select -> Properties
Select the Build tab.
Platform Target: x86
Then rebuild the project.
Background:
I had a perfectly good program working on 32 bit OS's. Then I bought a new laptop with Windows 7 64 Bit OS. Installed Visual Studio and my solutions. One project that processes windows messages to handle user input with WndProc failed. Yours is similar processing mouse messages.
After finding no patch by Microsoft's Visual Studio team, I changed the platform target from "Any CPU" to "x86", redeployed it to the 64 Bit OS, and saw program operate correctly. This was the only change.
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.