Arsen Zahray
Arsen Zahray

Reputation: 25367

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?

Upvotes: 4

Views: 2304

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1503839

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.

Upvotes: 11

Related Questions