停止CodeDom生成的可执行文件被检测为病毒

时间:2015-06-20 03:58:43

标签: c# codedom

因此,当我使用CodeDom生成一个C#程序并在线扫描时,它就会成为一种病毒。我怎么阻止这个? 这是我用来生成它的代码:

 string Output = "Out.exe";

    string[] fileArray = { "source.cs", "AssemblyInfo.cs" };

    CodeDomProvider codeProvider = CodeDomProvider.CreateProvider("CSharp");
    CompilerParameters parameters = new CompilerParameters();
    parameters.GenerateExecutable = true;
    parameters.OutputAssembly = Output;
    parameters.ReferencedAssemblies.Add("System.dll");
    CompilerResults results = codeProvider.CompileAssemblyFromFile(parameters, fileArray);

    if (results.Errors.Count > 0)
    {
        foreach (CompilerError CompErr in results.Errors)
        {
            MessageBox.Show(
                        "Line number " + CompErr.Line +
                        ", Error Number: " + CompErr.ErrorNumber +
                        ", '" + CompErr.ErrorText + ";" +
                        Environment.NewLine + Environment.NewLine);
        }
    }
    else
    {
        MessageBox.Show("Success!");
    }

这是我用于生成的exe

的代码
using System;
using System.Text;

namespace Out
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Text.StringBuilder sbMessage = new System.Text.StringBuilder();
            Console.WriteLine(sbMessage.Append("the result of adding (1+2) is " + (1 + 2).ToString()));
            System.Console.ReadLine();
        }
    }
}

因此,当我扫描生成的文件时,它会被检测为病毒,如VirusTotal链接https://www.virustotal.com/en/file/d19cb8ad9c9de9da50a29acab91b53d10327b3023aa1a32c367d17c0c50fd28c/analysis/1434772258/中所示

0 个答案:

没有答案