Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 727321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:33:16+00:00 2026-05-14T06:33:16+00:00

I’ve created my own little c# compiler using the tutorial on MSDN, and it’s

  • 0

I’ve created my own little c# compiler using the tutorial on MSDN, and it’s not working properly. I get a few errors, then I fix them, then I get new, different errors, then I fix them, etc etc.

The latest error is really confusing me.

---------------------------

---------------------------
Line number: 0, Error number: CS0006, 'Metadata file 'System.Linq.dll' could not be found;




---------------------------
OK   
---------------------------

I do not know what this means.

Can somebody please explain what’s going on here?

Here is my code.

MY SAMPLE C# COMPILER CODE:
using System;

namespace JTM
{
    public class CSCompiler
    {
        protected string ot,
            rt,
            ss, es;

        protected bool rg, cg;

        public string Compile(String se, String fe, String[] rdas, String[] fs, Boolean rn)
        {
            System.CodeDom.Compiler.CodeDomProvider CODEPROV = System.CodeDom.Compiler.CodeDomProvider.CreateProvider("CSharp");
            ot =
                fe;

            System.CodeDom.Compiler.CompilerParameters PARAMS = new System.CodeDom.Compiler.CompilerParameters();
            // Ensure the compiler generates an EXE file, not a DLL.
            PARAMS.GenerateExecutable = true;
            PARAMS.OutputAssembly = ot;

            foreach (String ay in rdas)
            {
                if (ay.Contains(".dll"))
                    PARAMS.ReferencedAssemblies.Add(ay);
                else
                {
                    string refd = ay;
                    refd = refd + ".dll";
                    PARAMS.ReferencedAssemblies.Add(refd);
                }

            }

            System.CodeDom.Compiler.CompilerResults rs = CODEPROV.CompileAssemblyFromFile(PARAMS, fs);

            if (rs.Errors.Count > 0)
            {
                foreach (System.CodeDom.Compiler.CompilerError COMERR in rs.Errors)
                {
                    es = es +
                        "Line number: " + COMERR.Line +
                        ", Error number: " + COMERR.ErrorNumber +
                        ", '" + COMERR.ErrorText + ";" +
                        Environment.NewLine + Environment.NewLine;
                }
            }
            else
            {
                // Compilation succeeded.
                es = "Compilation Succeeded.";

                if (rn) System.Diagnostics.Process.Start(ot);
            }
            return es;
        }
    }
}

… And here is the app that passes the code to the above class:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string[] f = { "Form1.cs", "Form1.Designer.cs", "Program.cs" };
            string[] ra = { "System.dll", "System.Windows.Forms.dll", "System.Data.dll", "System.Drawing.dll", "System.Deployment.dll", "System.Xml.dll", "System.Linq.dll" };
            JTS.CSCompiler CSC = new JTS.CSCompiler();
            MessageBox.Show(CSC.Compile(
                textBox1.Text, @"Test Application.exe", ra, f, false));
        }
    }
}

So, as you can see, all the using directives are there. I don’t know what this error means. Any help at all is much appreciated.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:33:16+00:00Added an answer on May 14, 2026 at 6:33 am

    Solution:

    Add this:

    PARAMS.ReferencedAssemblies.Add(typeof(System.Xml.Linq.Extensions).Assembly.Location);
    

    So the code now looks like this:

    namespace JTM
    {
        public class CSCompiler
        {
            protected string ot,
                rt,
                ss, es;
    
            protected bool rg, cg;
    
            public string Compile(String se, String fe, String[] rdas, String[] fs, Boolean rn)
            {
                System.CodeDom.Compiler.CodeDomProvider CODEPROV = System.CodeDom.Compiler.CodeDomProvider.CreateProvider("CSharp");
                ot =
                    fe;
    
                System.CodeDom.Compiler.CompilerParameters PARAMS = new System.CodeDom.Compiler.CompilerParameters();
                // Ensure the compiler generates an EXE file, not a DLL.
                PARAMS.GenerateExecutable = true;
                PARAMS.OutputAssembly = ot;
                PARAMS.ReferencedAssemblies.Add(typeof(System.Xml.Linq.Extensions).Assembly.Location);
                foreach (String ay in rdas)
                {
                    if (ay.Contains(".dll"))
                        PARAMS.ReferencedAssemblies.Add(ay);
                    else
                    {
                        string refd = ay;
                        refd = refd + ".dll";
                        PARAMS.ReferencedAssemblies.Add(refd);
                    }
    
                }
    
                System.CodeDom.Compiler.CompilerResults rs = CODEPROV.CompileAssemblyFromFile(PARAMS, fs);
    
                if (rs.Errors.Count > 0)
                {
                    foreach (System.CodeDom.Compiler.CompilerError COMERR in rs.Errors)
                    {
                        es = es +
                            "Line number: " + COMERR.Line +
                            ", Error number: " + COMERR.ErrorNumber +
                            ", '" + COMERR.ErrorText + ";" +
                            Environment.NewLine + Environment.NewLine;
                    }
                }
                else
                {
                    // Compilation succeeded.
                    es = "Compilation Succeeded.";
    
                    if (rn) System.Diagnostics.Process.Start(ot);
                }
                return es;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 403k
  • Answers 403k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you are running your updates on a per-pixel level,… May 15, 2026 at 5:17 am
  • Editorial Team
    Editorial Team added an answer IIRC, long on the iPhone/ARM is 32 bits. If you… May 15, 2026 at 5:17 am
  • Editorial Team
    Editorial Team added an answer You're facing a "dirty attributes" optimization that was introduced in… May 15, 2026 at 5:17 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.