How to compile C# code at runtime in an ASP.NET MVC5 project?

Asked

Viewed 147 times

1

I tried to use the CodeDom, but when trying to find a DLL specific to execute my code the command Assembly.GetEntryAssembly().Location always returns to me null.

It seems the projects ASP.NET are executed and managed by IIS (obviously) and use a temporary directory.

I would like a solution so that, in my web application, the user enters the code C# and then this code was sent to the server, compiled and executed to return a reply to the user.

In projects Windows or Console, everything works perfectly, but in a solution DDD with the Start Up Project as an application ASP.NET MVC5 that doesn’t work.

  • See if it helps you: https://answall.com/q/15428/101

  • @Maniero thank you for the answer, but that’s not quite what will solve my problem. I’ve tried to do it this way and it works for windows projects but not for ASP.NET projects, the real reason I’m not sure, but it has to do with the fact that ASP.NET projects are run by IIS and the same generate execution with TEMP files.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.