Stop CodeDom generated executables being detected as a virus

127 views Asked by At

So when i generate a C# program using CodeDom and scan it online it comes up as being a virus. How do I stop this? This is the code i am using to generate it:

 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!");
    }

This is the code i'm using for the generated 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();
        }
    }
}

So when I scan the generated file, its getting detected as a virus as showen in the VirusTotal link https://www.virustotal.com/en/file/d19cb8ad9c9de9da50a29acab91b53d10327b3023aa1a32c367d17c0c50fd28c/analysis/1434772258/

0

There are 0 answers