WPF Application Errors and .Net Framework Repairs

后端 未结 5 2204
囚心锁ツ
囚心锁ツ 2021-02-20 10:11

Background: I have a .Net 3.5 WPF \"Prism\"-based application running on Windows XP and Windows PosReady 2009 PCs. The app runs on PCs that are shut down every

相关标签:
5条回答
  • 2021-02-20 10:21

    We were finally able to get a hold of a production machine exhibiting this behavior and through a number of troubleshooting steps, including sending dump files to Microsoft, the issue was located.

    The WPF Font Caching Windows service was occasionally getting into a corrupted state, causing a simple cache request to block indefinitely. This hang caused all of the behaviors described above in the our WPF application.

    Simple solution: stop and disable the service. After disabling the service and rebooting the PC the service is no longer in use and we don't see any of these issues. In theory this leads to longer application load times, but we have seen zero negative impact.

    Note that there are two versions of the service: 3.0.0.0 and 4.0.0.0. If your application is targeting .Net 3.0 or 3.5 you'll need to disable the 3 service, and if targeting 4.0+ you'll need to disable the 4 service.

    Thanks to all for your comments and suggestions.

    0 讨论(0)
  • 2021-02-20 10:21

    We have had problems reminding of yours with our WPF application when connecting touch screens. This was due to a bug in the automation framework in .Net. It caused our application to either become very slow or entirely hang the GUI thread.

    You can read more about the problem at: http://social.msdn.microsoft.com/Forums/en-IE/windowsaccessibilityandautomation/thread/6c4465e2-207c-4277-a67f-e0f55eff0110

    The workaround suggested in the thread above where one removes any listeners of automation event periodically worked for us.

    This is not a real answer but since I do not have enough rep? (I guess) I can't use the comment function :)

    0 讨论(0)
  • 2021-02-20 10:21

    Try using ANTS profiler to see if you have a memory leak. You can find out easily with just the 2 week trial version that they give.

    0 讨论(0)
  • 2021-02-20 10:29

    Have you tried remote debugging the production system?

    What you need to remote debug are:

    • deploy msvcmon.exe
    • network connection between your development and production system
    • make sure your local and remote version of the code are in sync. You can also build on your dev machine, and xcopy deploy your debug build to the remote machine. If it's pure .net code that is the easy. If you also have C++ code you should make sure the debug versions of the C++ dlls are on the production machine. Or, build the release version and remote debug that.
    • setup a user account used for the connection. This is actually a bit tricky. Google remote debugging credentials for a few tips.
    • don't forget to disable all firewalls!

    You can attach to an already running process, but you can also start the app from inside visual studio.

    If your development system is located far away from the production system, use a laptop and remote desktop to bring your developer studio to the production system. I do this routinely. Even a five metre distance between the two is annoying.

    I can elaborate on this, if there's interest, or if you run in to trouble setting up the connection.

    Good luck!

    0 讨论(0)
  • 2021-02-20 10:34

    Try a global Error catch and see what it produces.

     public partial class App : Application
        {   
            [STAThread]
            public static void Main()
            {
                    var application = new App();
    
                    application.DispatcherUnhandledException += 
                        new DispatcherUnhandledExceptionEventHandler(application_DispatcherUnhandledException);
    
                    application.InitializeComponent();
                    application.Run();
            }
    
            static void application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
            {
                LogAndClose("Global exception: " + e.Exception.ToString());
            }
    
            public static void Log(string text)
            {
                try
                {
                    System.IO.File.AppendAllText(Environment.CurrentDirectory + "\\Log.txt",
                        "[" + DateTime.Now.ToString("MM/dd/yy HH:mm:ss") + "] " + text + "\r\n");
                }
                catch { }
            }
    
            public static void LogAndClose(string text)
            {
                Log(text);
    
                try
                {
                    Application.Current.Shutdown();
                }
                catch { }
            }
        }
    
    0 讨论(0)
提交回复
热议问题