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 7948731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:48:23+00:00 2026-06-04T01:48:23+00:00

Right now I’m working on a project, and the team wants a way to

  • 0

Right now I’m working on a project, and the team wants a way to write code and edit it without having to recompile the whole project, so I’ve decided to try and implement a scripting engine.

Having implemented Lua into C++ before, I wasn’t an entire newbie to implementing scripting capabilities into projects. However, we wanted to try and implement straight C# using the Microsoft.CSharp namespace, combined with System.Reflection that was already built in to C#.

So having hearing about this, I poked about in docs and I’ve come up with a prototype that ALMOST works – but doesn’t quite.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.CSharp;
using System.CodeDom.Compiler;
using System.Reflection;

namespace Scripting
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("using System;");
            builder.Append("using Scripting;");
            builder.Append("class MyScript : IScript");
            builder.Append("{");
            builder.Append("    string ScriptName");
            builder.Append("    {");
            builder.Append("        get { return \"My Script\"; }");
            builder.Append("    }");

            builder.Append("    public bool Initialize()");
            builder.Append("    {");
            builder.Append("        Console.WriteLine(\"Hello, World!\");");
            builder.Append("        return true;");
            builder.Append("    }");
            builder.Append("}");

            CSharpCodeProvider provider = new CSharpCodeProvider();
            CompilerParameters param = new CompilerParameters(new string[] { "System.dll", "Scripting.dll" });
            param.GenerateInMemory = true;
            param.GenerateExecutable = true;
            CompilerResults result = provider.CompileAssemblyFromSource(param, builder.ToString());
            if (result.Errors.Count > 0)
            {
                foreach (CompilerError error in result.Errors)
                    Console.WriteLine(error);
                Console.ReadKey();
                return;
            }
        }
    }
}

The issue I have at the moment is that I want to be able to reference my interface – IScript.cs (which is inside the Scripting namespace and thus, the current assembly) – so that scripts written and parsed in the compiler can access it. Obviously, I added Scripting.dll as a parameter, but it doesn’t seem to be able to be accessed for some reason or another. I am running it in debug so this could be cause for some major facepalmage. What do?

Is there a way to reference the current assembly and pass it to CompilerParameters? Or am I royally screwed / should I rely on creating an assembly for script objects / etc?

  • 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-06-04T01:48:24+00:00Added an answer on June 4, 2026 at 1:48 am

    It’s probably looking in the wrong directory.

    Pass typeof(Program).Assembly.Location to pass the full path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I'm working on small project, submitting very simple jobs and I'm working
Right now, I've just some code which fetches the picture from the URL directly.
Right now I'm working on a Internet Explorer add on which is supposed to
Right now I am writing some Python code to deal with massive twitter files.
Right now I've been maintaining a second sandbox project where I test concepts and
Right now I am listing all of a users microposts using the code below.
Right now I have the following code: if (c > last) break; And jslint
Right now, I am closing all the opened windows. I want to write a
Right now I'm having this issue in Eclipse where I have an XML file
Right now, when I use write system call over and over again, it just

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.