Visual Studio和MSSE防病毒编译时间错误 [英] Visual studio and MSSE antivirus compile time bug

查看:107
本文介绍了Visual Studio和MSSE防病毒编译时间错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的VS2013 Ultimate副本编译了这段代码60多秒:

My copy of VS2013 Ultimate compiles this code for 60+ seconds:

class Program
{
    static void Main(string[] args)
    {
        double dichotomy = Dichotomy(
            d =>
            {
                try
                {
                    int size = (int) d;
                    byte[] b = new byte[size];
                    return -b.Length;
                }
                catch (Exception)
                {
                    return 0;
                }
            },
            0,
            int.MaxValue,
            1);

        Console.WriteLine(dichotomy);
        Console.ReadKey();
    }

    private static double Dichotomy(
        Func<double, double> func,
        double a,
        double b,
        double epsilon)
    {
        double delta = epsilon / 10;
        while (b - a >= epsilon)
        {
            double middle = (a + b) / 2;
            double lambda = middle - delta, mu = middle + delta;
            if (func(lambda) < func(mu))
                b = mu;
            else
                a = lambda;
        }
        return (a + b) / 2;
    }
}

但是,如果我替换 double int ,它会立即编译。如何解释??

But if I replace double with int, it compiles immediately. How can be it explained...?

推荐答案

我在我的机器上复制了27秒。邪恶的人是MsMpEng.exe,它长达100%的核心。在任务管理器的进程选项卡中可以轻松查看。

I repro, 27 seconds on my machine. The evil-doer is MsMpEng.exe, it burns 100% core for that long. Easy to see in Task Manager's Processes tab.

这是Windows Defender服务,实际执行恶意软件扫描。通过取消启用打开实时保护选项即可立即修复延迟。所以添加我将项目存储到排除的文件位置框中的路径,可能是您首选的方法。

This is the Windows Defender service, the one that actually performs the malware scans. Disabling it by unticking the "Turn on real-time protection" option instantly fixes the delay. So does adding the path where I store projects to the "Excluded file locations" box, probably your preferred approach.

我不喜欢猜测底层原因,但必须假定您的源代码触发恶意软件规则。不是一个很好的解释,我没有看到延迟,当我的目标.NET版本< 4.0。好的,我放弃了:)

I'd hate to have to guess at the underlying reason, but have to assume that your source code is triggering a malware rule. Not a great explanation, I don't see the delay when I target a .NET version < 4.0. Okay, I give up :)

这篇关于Visual Studio和MSSE防病毒编译时间错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆