应用程序启动缓慢

应用程序启动缓慢

本文介绍了WPF 应用程序启动缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 WPF 应用程序目前只显示带有一些控件的屏幕,它没有连接到数据库或具有任何其他功能.这是一个简单的 UI 屏幕.

当我在某些计算机 (WinXP SP2) 上进行测试时,我发现启动时间超过 15 秒.它们都在我们的域中.

我拿了一台类似的电脑,只安装了 Windows,应用程序启动需要 2 秒钟.

然后我将计算机添加到我们的域中,并使用域用户对其进行测试表明它也需要 15 秒才能启动.我用以前的用户(本地用户)再次测试,它仍然很快.我创建了另一个本地用户,但域用户也需要 15 秒.我添加了其他本地用户,但他们也很慢.

总结:该应用程序仅在一个用户(我测试的第一个用户)中快速启动(2 秒).所有其他用户(域或本地)都很慢(15 秒).

我一直在检查 改进 WPF 应用程序启动时间 但我的问题似乎需要不同的方法.有人知道会发生什么吗?

解决方案

我在这个 Microsoft 文档.

在app.config文件中加入如下配置也可以解决问题:

<运行时><generatePublisherEvidence enabled="false"/></运行时></配置>

这样,您就无需更改计算机配置.这只是应用程序的配置.

更新:
似乎 .NET 4.0 解决了这个问题,如 在这里在 MSDN 上.

My WPF application currently only shows a screen with some controls, it doesn't connect to DB or has any other functionality. It's a simple UI screen.

When I was testing in some computers (WinXP SP2), I've detected that it took more than 15 seconds to startup. They were all in our domain.

I've grabbed a similar computer, only with Windows installed, and the application took 2 seconds to startup.

Then I added the computer to our domain, and testing it with a domain user showed that it also took 15 seconds to startup. I tested again with the previous user (local user) and it's still fast. I created another local user, but it takes the 15 seconds that the domain user also takes.I've added other local users but they were also slow.

To summarize: the application starts fast (2 sec) in only one user, the first one I tested. All other users (domain or local) are slow (15 sec).

I've been checking Improving WPF applications startup time but my problem seems to need a different approach. Does anyone figure out what can be happening?

解决方案

I found another solution to this problem in this documentation from Microsoft.

Adding the following configuration to the app.config file will also solve the problem:

<configuration>
    <runtime>
        <generatePublisherEvidence enabled="false"/>
    </runtime>
</configuration>

This way, you don't need to change computer configurations. It's just configuration of the application.

UPDATE:
Seems that .NET 4.0 fixed this issue, as documented here on MSDN.

这篇关于WPF 应用程序启动缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 23:47