操作方法诊断和修复等"现场"的dotnet的应用程序崩溃?操作方法、应用程序、现场、QUOT

2023-09-06 23:54:30 作者:哟哟发Q闹

我工作的一些应用程序,它具有自动更新功能。所实施的想法很简单如下:   - 有它安装到Program Files文件/不管/ ......一些启动器的应用程序。它的,其目的是由用户启动该应用程序。   - 在启动器的应用程序执行时,每次检查服务器的更新和下载到%APPDATA%/一些/ ...。然后,它开始从该文件夹中的一些应用程序。

上面的方法正在自己的计算机(运行Vista)和XP下的一些其他的机器,但是在一些不同的机器上(运行Windows 7),它是不工作。当启动器执行真正的应用程序崩溃与一些未知的问题(签名= System.UnauthorizedAccess)。在实际应用时手动%APPDATA%执行/部分/文件夹,然后一切工作正常。我试图在的ProcessStartInfo设置相同的工作目录,因此启动器也将在该文件夹中运行实际的应用,但是这不是帮助了我。

如何诊断和/或修复这个问题?

更新 如何我运行的主要过程的详细信息,从首发:

 私有静态只读字符串_ROOT = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),MyApp的);
...
        私有静态无效的run()
        {
            字符串startPath = Path.Combine(_ROOT,MyApp.exe将);
            的ProcessStartInfo的StartInfo =新的ProcessStartInfo();
            startInfo.FileName = startPath;
            startInfo.WorkingDirectory = _ROOT;
            的Process.Start(startPath);
        }
 

此可靠地启动的正确过程,因为应用程序窗口可以看到的,但一些磁盘或网络操作可能是由视窗否认和启动过程被坠毁。 更新 显示的跟踪的工作目录是不正确的,而且指出了不正确的Process.Start(string)方法调用在我的code。正确的路线:

 的Process.Start(StartInfo的);
 

解决方案

对于你的问题,我给出的赔率认为,坠机是无论是从缺少资源或依赖或它的权限问题。您是否尝试过运行使用管理员权限的应用程序?一般情况下,的Windows XP中,因为每一个版本得到了越来越多的限制,这是.NET运行时尤其如此。你是依赖于第三方库或DLL?

至于诊断问题,假设你没有访问到远程机器上的一个调试器,最好的办法是大量使用System.Diagnostics.Trace的。您可以跟踪配置从你的app.config并跟踪重定向到一个本地文件很容易。另外,请务必检查事件查看器中的任何应用程序级的异常。

随着时间的推移,以及足够的跟踪语句,你应该找到问题的速度不够快。

启用跟踪是因为添加以下到您的app.config一样容易。

 < System.Diagnostics程序>
    <跟踪自动冲洗=真indentsize =3>
      <听众>
        <添加名称=fileOutListenerTYPE =System.Diagnostics.TextWriterTraceListenerinitializeData =C:\ Path.to \文件\的debug.log/>
      < /听众>
    < /跟踪>
  < /system.diagnostics>
 
Windows7网络无法使用提示 诊断策略服务未运行 怎么办

然后在你的code地址:

  System.Diagnostics.Trace.Writeline(System.DateTime.ToString()+::现在我在XX位置做YY);
 

I'm working on some application which has auto-update function. The implemented idea is simple as following: - There are some "starter" application which is installed to "Program Files/whatever/...". It's the application which is intended to be started by user. - Each time the "starter" application is executed it checks server for updates and downloads it to "%APPDATA%/some/...". And then it starts some application from that folder.

Above approach is working on my development machine (running Vista) and on some other machines under XP, but under some different machine (running Windows 7) it isn't working. When "starter" executes the real application it crashes with some unknown problem (Signature = System.UnauthorizedAccess). When real application is executed manually from %APPDATA%/some/ folder then everything is working fine. I've tried to set same working directory in ProcessStartInfo, so "starter" will also execute real application in that folder, but this isn't helped me.

How can I diagnose and/or fix that issue?

Update More details on how I'm running main process from starter:

        private static readonly string _ROOT = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MyApp");
...
        private static void Run()
        {
            string startPath = Path.Combine(_ROOT, "MyApp.exe");
            ProcessStartInfo startInfo = new ProcessStartInfo();
            startInfo.FileName = startPath;
            startInfo.WorkingDirectory = _ROOT;
            Process.Start(startPath);
        }

This surely starts the correct process because application window can be seen, but some disk or network operation is probably denied by Windows and started process is crashed. Update The tracing shown that working directory wasn't correct and that pointed to incorrect Process.Start(string) method call in my code. The correct line:

    Process.Start(startInfo);

解决方案

As to your problem, I give odds that the crash is either from a missing resource or dependency or its a permissions issue. Have you tried running the app using administrator permissions? Generally, every version of Windows since Xp got more and more restricted and this is especially true of the .net runtime. Are you dependent on third party libraries or DLLs?

As to diagnosing the problem, assuming you don't have access to a debugger on the remote machine, your best bet is ample use of System.Diagnostics.Trace. You can make the tracing configurable from your app.config and have the trace redirect to a local file easy enough. Also make sure to check the Event Viewer for any application level exceptions.

With time, and enough trace statements, you should find the problem quickly enough.

Enabling Tracing is as easy as adding the following to your app.config.

<system.diagnostics>
    <trace autoflush="true" indentsize="3">
      <listeners>
        <add name="fileOutListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\Path.to\File\debug.log" />
      </listeners>
    </trace>
  </system.diagnostics>

Then throughout your code add:

System.Diagnostics.Trace.Writeline(System.DateTime.ToString() + " :: I am currently at XX location doing YY");