Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile c# code into memory?

I'm using Microsoft's CSharpCodeProvider to dynamically create and execute code.

Right now, it creates an assembly in a dll, located inside a temporary folder.

I want for it to create an assembly in memory without having to write it to a hard drive.

How do I do that?

like image 351
Arsen Zahray Avatar asked Dec 21 '22 20:12

Arsen Zahray


1 Answers

I think you're just looking for CompilerParameters.GenerateInMemory.

Set that to true for the compiler parameters you pass in when compiling, and it won't generate a file.

like image 97
Jon Skeet Avatar answered Dec 24 '22 00:12

Jon Skeet