-2

I am a student and I am during my final project.

In my project I give an option to edit code and run it. The problem is, that I do not know how to create a new exe file after changing the code.

I would be happy if you can help me !!!

Thank you very much!

marc_s
  • 704,970
  • 168
  • 1,303
  • 1,425
  • Possible duplicate of [Compiling/Executing a C# Source File in Command Prompt](https://stackoverflow.com/questions/553143/compiling-executing-a-c-sharp-source-file-in-command-prompt) – Klaus Gütter Feb 18 '19 at 20:28
  • This should allow you to compile the code using CMD : https://stackoverflow.com/questions/553143/compiling-executing-a-c-sharp-source-file-in-command-prompt – YouneS Feb 18 '19 at 21:02

1 Answers1

1

You can compile code into assemblies and then execute them as such.

This example should cover what I mean:

https://csharp.hotexamples.com/examples/System.CodeDom.Compiler/CodeDomProvider/CompileAssemblyFromFile/php-codedomprovider-compileassemblyfromfile-method-examples.html

You can access the compiled assembly from CompiledResults and run it directly in the current AppDomain like a script of some sorts or you can store it to an .exe

JCode
  • 1,419
  • 9
  • 17
  • i don't know why someone downvoted this. this is amazing info. – John Lord Feb 18 '19 at 20:48
  • @JohnLord I think so too :) – JCode Feb 19 '19 at 06:09
  • I used the code that you gave me in the example and there is a very big problem... it doesn't recognize the namespace he is in... do you have any idea how can i solve it? Thank you anyway!!!! – Ayala Finch Mar 25 '19 at 20:10
  • @AyalaFinch You can specify the namespace when calling it, I assume you have issue with the MainClass. Just do 'MyNamespace.MyClass'. – JCode Mar 25 '19 at 21:48