I have a WPF application that is hanging on one user's machine. Other users aren't affected. The app hangs both running natively out of the development environment and whilst running under debug. The problem can be reproduced reliably - it simply hangs whatever the user attempts to do. Running under debug offers no clues, no exception is thrown, the app simply stops responding.
What options do I have for debugging this? Are there any external tools - things like sysinternals suite for example - that can help? Are there any Visual Studio debugger tricks or tips that might provide a bit more info?
Yes, you can use mdbg.exe to attach to the hanging process (a PID) and when you are there press w to see the stack trace.
btw. the hanging could possibly be caused by the corrupted font cache so before you try the mdbg try to find the instruction on how to clear the WPF's font cache.
Since this is a rather general description only general pointers:
hit "pause" in the debugger and see where it hangs
patch the system + drivers to the latest "stable level"
check any 3rd-party assemblies you are using
perhaps there is some quirk regarding version and/or configuration and/or dependency
use sysinternal processmon to check what the app does (which files are accessed etc.)
check network connectivity and configuration (proxy, DNS, firewall etc.) if your app uses anything (like a network share or DB or internet access etc.)
check RAM (perhaps the machine is paging like crazy...)
if your app is multi-threaded there can be exceptions "lurking" => try adding global handlers to get a clue (see here)
Font problems can be another issue to account for... see here
check for antivirus etc. => these can sometimes create strange behaviour
anything of the above could give you a clue what's going on.
Check your hardware acceleration for the machine. Remember WPF uses direct hardware access for rendering when available. You can try reducing your acceleration, updating your video drivers, etc.
What operating system is this running under? If Windows 7 - is Aero enabled?
Related
Using Visual Studio Community 2022 targeting .Net 4.7.2. I create a new C# ASP.Net 4.7.2 web project (NO CORE)
I did not make any changes to the code, project, or solution. I press play after the project creation and the application crashes. The error starts out "Managed Debugging Assistant 'FatalExecutionEngineError'" followed by 'System.ExecutionEngineException'
I came to SO and researched this issue and I have found some decent looking posts. My crash is different. This is not crashing in user code. The first line of the call stack shows the crash happened in external code.
I've tried all the hacks in Component Services to grant permissions. I've tried modifying the registry directly but my company group policy does not allow this.
I've looked in the event viewer and found some interesting information and tried to act on it (read above)
The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID
{2593F8B9-4EAF-457C-B68A-50F6B8EA6B54}
and APPID
{15C20B67-12E7-4BB6-92BB-7AFF07997402}
to the user THA\Andy2394 SID (S-1-5-21-117609710-507921405-1801674531-26297) from address LocalHost (Using LRPC) running in the application container Unavailable SID (Unavailable).
What is a 'Unavailable SID'? That doesn't seem correct to me. I thought everything had a SID to it. Do I need to check and fix any disk errors?
This local comserver executable is called RuntimeBroker.exe.
I can only suspect that code in RuntimeBroker.exe or code that it raises before entering my code is considered dangerous to the CLR.
This problem is driving me batty and it is preventing me from doing my job. Aside from reimaging machine and starting over hoping it is something microsoft related and related to order of operation on installation, I need some direction please.
Though I am calling this "an answer", it is not satisfying at all. My organization uses Cylance. Since I am an admin in our organization, I removed my machine from its list of machines to protect. That solved the problem.
Others have mentioned Cylance so they deserve most of the credit for this answer that is not an answer.
!!!I would not recommend this!!!
Update: The previous answer is not complete. Sorry. I have been dealing with this for 2 days and didn't capture all my info.
In order to continue with my answer that I don't recommend, you need to boot into safe mode.
Then add a DWORD32 to HKEY_LOCAL_MACHINE\SOFTWARE\Cylance\Desktop called "SelfProtectionLevel" and set the value to 1.
Reboot
You now should be able to stop the Cylance service and uninstall it and find a better A/V that works for engineers.
Sorry that this whole adventure put a sour taste in my mouth and a rankerous oder in my nose.
I guess I understand that software development by nature would be considered dangerous to AV software. Where's a video of McAffee breaking the law. I need a laugh.
I am working in VisualStudio 2010 SP1 on an application server system written in C#. (Yes this is a legacy application.) The system is a large multi-threaded server application that provides a large SOAP API along with newer REST APIs for other portions of the system.
For a long time I have noticed that occasionally when starting the system in debug mode both the server and VisualStudio would stall. Neither UI would respond and calls to the server APIs would block. This situation could be recovered from only by halting the server using Task Manager, after which VisualStudio would complain with an error.
Recently this problem became persistent, that is it happens every time. The lock up occurs at various times, that is I have not been able to identify a specific time when the system locks up, it may (often) happen as soon as the server is started, other times it may take a minute or so, but always shortly after startup, both VisualStudio and the server lock up.
If I try to do something in the VisualStudio UI, e.g. pressing the Pause button, I will get the "Microsoft Visual Studio Delay Notification" icon in the notifications section of the Windows task bar.
I have done some investigation on the web and have tried the following unsuccessfully:
Clean rebuild
Removing all build products from the directory structure
Doing a clean checkout in a new directory structure
resetiis
Removing the .suo files
Resetting the VisualStudio settings
I have also tried creating both mini & full dumps of both the application and devenv, but I have not been able to understand them well enough to find any issue.
What would you do to try to identify the issue?
The solution to my issue turned out to be working on the program using VS2015. This is not a wonderful solution since we still build in VS2010, but it at least allowed me to proceed. We are not sure exactly what caused the issue.
I have a WPF application which will be used on tablets with Windows 10.
In my development environment, the application runs very fast. However, if I run the application on tablet without admin rights, the application responds very slow : all animations are slow, the scrolling is not smooth, and touch problems are visible (cannot move the caret). If the application has admin rights all things are working fine.
I tried to disable the logs, I tried to decrease the FPS, nothing seems to help.
My application is connected to a sqlite database, but even without accessing the database is very slow. There are no other connections that may require admin rights.
What could be the problem?
EDIT: Also in my dev environment the app is running slower without admin rights. I was running the VS2015 with admin rights and for that reason the application worked fine.
WPF has settings under HKEY_CURRENT_USER that can disable hardware acceleration:
https://msdn.microsoft.com/en-us/library/aa970912(v=vs.110).aspx
If the Disable Hardware Acceleration Option or the Use Reference Rasterizer Option are set, a WPF application will run slowly for that user.
Try to trace your app with Process Monitor. Run 2 traces for app running with and without admin rights. Filter your app events only via Tools->Process Tree... -> right click on your process -> Add to Include filter and compare these trace logs (or just post them here). Pay attention on gaps between registry key readings or network access.
That literally could be anything.
Mark Russinovich make a presentation almost every year about finding some interesting cases. Here's one of them.
P.S. I'm sorry to post that as an answer, but I don't have enough points to add comments right now.
To offer an answer for people that might face the same issue, now, after I've searched a lot for something helpful, I can say that this problem it is mainly a problem related to rights.
If you encounter this issue, try to run Visual Studio without admin rights and try to isolate the region where the application begins to act very slow (or the place were it crashes) . In my case, wasn't the database, or the log files, but a file in AppData which was used by an external assembly. I've seen that, every time that dll was called, the application was freezing and using dotTrace, I've managed to find which file it is used. After setting the rights (r/w) on that file, everything was back to normal.
A few applications on my PC have been doing a detection wether a restart was done by Windows Update or not. This is observable due to them restarting after the automatic Windows Update reboot.
This is very helpful since those applications reload changes, even unsaved changes or restore tabs (in case of a browser). Examples of applications that do this:
Google Chrome
Microsoft Visual Studio
Microsoft Paint
In all cases the applications save the state they were in before the reboot.
(My PC actually woke up from a standby state automatically, and rebooted itself while instaling updates. Too bad it didnt go back to standby after doing this.)
My question is: How do I programmatically detect this kind of reboot? It seems to be reliably detectable before the reboot.
The question How can I get the Windows last reboot reason might seem like a duplicate, but no answer said anything about updates.
I code in C#, so an answer in C# would be helpful, though I can read C and C++ too, for example.
See Application Restart:
An application can use Application Recovery and Restart (ARR) to save data and state information before the application exits due to an unhandled exception or when the application stops responding
and:
or if the computer needs to restart as the result of an update.
The applications aren't detecting the restart reason after the fact - they've been architected to use this API. There isn't (so far as I'm aware) a managed API for this.
A couple of clicks away is Saving data and application state when application is being closed due to a software update. Again, no managed API.
Normally when Windows Reboots, it performs a restart by using shutdown.exe and the /g flag which saves the state of all registered running programs before restart. What you want to do is to Register your application for restart. There is a good sample with documentation for this by MSDN. It is available in C# and C++.
I want to enable desktop composition on a Windows 7 machine programmatically (preferrable C#) and already tried to do it with the infamous DwmEnableComposition P/Invoke. However, this does not seem to work if DWM has never been enabled (and the performance test has not run). I can, however, enable DWM via the "Personalization" control panel w/o running the performance test.
My question therefore is: how can I do the same programmatically? And a second question: how can I achieve that a change in the setting is persistent (e. g. if I set DwmEnableComposition(false) on a machine that has DWM enabled, it is re-enabled once the application exits)?
I found a less nasty solution than my first one: Invoking winsat dwm will turn on Aero automatically once it finishes and if the hardware supports it - and it does not change the wallpaper etc.
The answer is: You cannot do that.
Microsoft does not expose a programmatic way for programs to enable or disable desktop composition on the user's machine.
The reason they don't provide an API is that programs might use it.
In the past Microsoft trusted developers not to do the wrong thing. That has changed
Because programmers were trusted to do the right thing
DwmEnableComposition is only for your application to temporarily disable DWM if you aren't compatible with composition. It cannot be used to turn on composition, when the user has already turned it off.
Any computer sold in the last 5 years is graphically capable of using composition, and Windows turns it on by default if its supported. The only reason it would be turned off is:
the user turned it off
another application is running that doesn't support composition
In either case: you should not (and therefor cannot) turn it on.
You cannot do that.