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

  • Home
  • SEARCH
  • 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 336475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:14:45+00:00 2026-05-12T10:14:45+00:00

Let’s say that I have two C# applications – game.exe (XNA, needs to support

  • 0

Let’s say that I have two C# applications – game.exe (XNA, needs to support Xbox 360) and editor.exe (XNA hosted in WinForms) – they both share an engine.dll assembly that does the vast majority of the work.

Now let’s say that I want to add some kind of C#-based scripting (it’s not quite “scripting” but I’ll call it that). Each level gets its own class inherited from a base class (we’ll call it LevelController).

These are the important constraints for these scripts:

  1. They need to be real, compiled C# code

  2. They should require minimal manual “glue” work, if any

  3. They must run in the same AppDomain as everything else

For the game – this is pretty straight forward: All the script classes can be compiled into an assembly (say, levels.dll) and the individual classes can be instanced using reflection as needed.

The editor is much harder. The editor has the ability to “play the game” within the editor window, and then reset everything back to where it started (which is why the editor needs to know about these scripts in the first place).

What I am trying to achieve is basically a “reload script” button in the editor that will recompile and load the script class associated with the level being edited and, when the user presses the “play” button, create an instance of the most recently compiled script.

The upshot of which will be a rapid edit-test workflow within the editor (instead of the alternative – which is to save the level, close the editor, recompile the solution, launch the editor, load the level, test).


Now I think I have worked out a potential way to achieve this – which itself leads to a number of questions (given below):

  1. Compile the collection of .cs files required for a given level (or, if need be, the whole levels.dll project) into a temporary, unique-named assembly. That assembly will need to reference engine.dll. How to invoke the compiler this way at runtime? How to get it to output such an assembly (and can I do it in memory)?

  2. Load the new assembly. Will it matter that I am loading classes with the same name into the same process? (I am under the impression that the names are qualified by assembly name?)

    Now, as I mentioned, I can’t use AppDomains. But, on the other hand, I don’t mind leaking old versions of script classes, so the ability to unload isn’t important. Unless it is? I’m assuming that loading maybe a few hundred assemblies is feasible.

  3. When playing the level, instance the class that is inherited from LevelController from the specific assembly that was just loaded. How to do this?

And finally:

Is this a sensible approach? Could it be done a better way?


UPDATE: These days I use a far simpler approach to solve the underlying problem.

  • 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-12T10:14:45+00:00Added an answer on May 12, 2026 at 10:14 am

    Check out the namespaces around Microsoft.CSharp.CSharpCodeProvider and System.CodeDom.Compiler.

    Compile the collection of .cs files

    Should be pretty straightforward like http://support.microsoft.com/kb/304655

    Will it matter that I am loading classes with the same name into the same process?

    Not at all. It’s just names.

    instance the class that is inherited from LevelController.

    Load the assembly that you created something like Assembly.Load etc. Query the type you want to instanciate using reflection. Get the constructor and call it.

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

Sidebar

Related Questions

Let's say you have a project that will involve two web applications (that will
Let's say that I have two .Net applications running on a single machine. Both
Let's say that I have two libraries (A and B), and each has one
Let's say we have two objects. Furthermore, let's assume that they really have no
Let's say I have two tables that look like this: TH TH TH TH
Let's say I have two strings like this: XABY XBAY A simple regex that
Let's say we have two concave 2d polygons(A, B), that don't intersect. The problem
Let's say I have a structure named vertex with a method that adds two
I'm new to WCF. Let's say I have two asp.net apps, one that uses
This is for an Android application. Let's say that I have two colors with

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.