Questions tagged [csharpcodeprovider]

.NET class that provides access to the C# compiler for compiling code.

CSharpCodeProvider can be used by applications to compile C# source code from in-memory strings or from files on disk, producing in-memory compiled assemblies or DLL files on disk.

153 questions
0
votes
1 answer

How to terminate a dynamic executed code using CSharpCodeProvider?

I am developing a website which let user type in their code and run to show output (just like Linqpad). I used CSharpCodeProvider but I also want to set timeout for the code, so that it will not break system if their code is too slow or have…
chinh nguyen van
  • 729
  • 2
  • 7
  • 18
0
votes
1 answer

Generating DLL assembly at run time and change it?

i created a dll contains a class named PersonVM like what you see below. and its working ... public ActionResult Index() { using (CSharpCodeProvider codeProvider = new CSharpCodeProvider()) { …
Iman Salehi
  • 908
  • 2
  • 14
  • 34
0
votes
1 answer

Rreference run-time compiled assembly in other run-time compiled assembly

I'm trying to compile code at runtime that is referenced by an object that is also compiled at run-time in C# .NET 4.6. I'm using CSharpCodeProvider to generate a CompilerResult in memory. The resulting assembly is referenced in the 2nd code…
anhoppe
  • 4,287
  • 3
  • 46
  • 58
0
votes
1 answer

Set Variable Value using CSharpCodeProvider

I was wondering if there is any way to pass a variable value in a code that will be compiled One Time using CSharpCodeProvider . for example : string code = @" using System; namespace First { public class Program { public int Value;…
Left panda
  • 148
  • 2
  • 15
0
votes
2 answers

Creating an executable file with an icon from another assembly

I'm looking for a way to take an icon from an executable, and create a new executable (using CSharpCodeProvider) that uses this icon. The first part is easy, I do it using: Icon icon = Icon.ExtractAssociatedIcon(path); The problems come when I want…
Stud
  • 521
  • 4
  • 8
0
votes
2 answers

Namespace not found error when compiling assembly from files

What I'm trying to achieve is generate a project dynamically from c# classes generated by me. This classes' content are a similar content of code-first code generation of entity framework.The content looks as follows: namespace ElasticTables { …
0
votes
1 answer

Where should I put code compiled from CodeDOM Graph in my Prism modular application if this code must be accessable from any Prism module?

I develop Prism 6 WPF MVVM modular application. The solution of my application comprising one Shell project and many Prism module projects. In my application I have to realize Dynamic Source C# Code Generation and Compilation (CodeDom). I assume put…
Dr.Doog
  • 197
  • 4
  • 14
0
votes
2 answers

Loading assembly dynamically from a Typeprovider

I'm trying to add a feature to a type provider I'm working on to allow the user to specify a type. with Since type providers cannot provide generic methods, it seems the only way to do it is to reference the assembly that has the type. I've tried to…
Isak
  • 1,591
  • 1
  • 17
  • 23
0
votes
0 answers

Return string from Main() with CSharpCodeProvider

I'm trying to compile C# code(nothing too complex, just Main() ) using CSharpCodeProvider. This code returns a string, but I can't understand how to pass this value to my function. Is it possible? public string Execute(List code,…
0
votes
0 answers

Performance issue using CSharpCodeProvider in .Net MVC

I had a requirement where user can create and store conditions in database for eg. if(FB > 5000) then 100 else 200 it is working fine user can create the formula but my main main problem is executing that formula so at runtime FB gets replaced…
Nilesh Gajare
  • 6,302
  • 3
  • 42
  • 73
0
votes
0 answers

badimageformatexception dynamic code generation

I'm trying to dynamically generate an executable with the CSharpCodeProvider whose only purpose is to invoke one single method from a specific dll. When I execute the generated file I get a BadImageFormatException. I already set the platform to x86.…
0
votes
1 answer

How to access a compiled assembly from CSharpCodeProvider without recompiling

I have Microsoft.CSharp.CSharpCodeProvider CompileAssemblyFromSource working. Its definitely creating and returning what i need. I know the compiled code ends up in the assembly, and cann ont be removed until the app domain is dispossed of. How do…
Yogurt The Wise
  • 4,379
  • 4
  • 34
  • 42
0
votes
1 answer

Create Class object from string containing source code

I'm creating a C# application in which code is compiled at runtime, the code is contained in a string (and the string gets its value from a ScintillaNET Control, it just returns text, the string with code is working as intended). My question is: is…
0
votes
0 answers

CSharpCodeProvider: Referencing a different version of referenced assembly

Suppose Project Main has a reference to Project Ref. In Main, I have defined a CSharpCodeProvider and use it to compile code at runtime. var provider = new CSharpCodeProvider(new Dictionary { { "CompilerVersion", "v4.0" } }); var…
Kamyar
  • 18,639
  • 9
  • 97
  • 171
0
votes
1 answer

CSharpCodeProvider Compiling Order

Is there a way to compile files automatically in the right order. Seems like 'CompileAssemblyFromFile' do not care about dependencies before compiling. Way around ? public bClass { public aClass FieldName; //Trows error not aClass type not…
MR.ABC
  • 4,712
  • 13
  • 44
  • 88