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
2
votes
1 answer

CSharpCodeProvider, progress info while compiling

I generate some code in memory from random size data. This can generate something like 15K classes, and could be even more. The code is stored in a List that I use with the CompileAssemblyFromSource method from the CSharpCodeProvider class. The…
2
votes
1 answer

How to pass variables from windows application to asp website?

I am trying to build a desktop interface for my my website and want to pass variable to the asp sever.but couldn't find a proper way to pass these values more concisely i want to pass variables from separate window form application to a separate…
Sana
  • 71
  • 1
  • 2
  • 9
2
votes
1 answer

C# csharpcompiler compiler assembly cannot import anything

ive been trying adding a command system to a server application The problem is: the command .cs files that are not inside the project but they are compiled from another folder on runtime can't incude anything. the compiler code: static…
JMgamerZzz TM
  • 88
  • 1
  • 9
2
votes
1 answer

C# Runtime Compilation with CSharpCodeProvider

I have had success using this tutorial: http://www.codeproject.com/Tips/715891/Compiling-Csharp-Code-at-Runtime to set up a framework for runtime compilation and execution of C# code. Below is the code I currently have: public static class…
Dan Brenner
  • 880
  • 10
  • 23
2
votes
1 answer

How can I dynamically run a C# project

I am coding a C# Winforms application where the user can create and run their own dynamic scripts using the CSharpCodeProvider class. I have this working successfully with simple code (as a string), and multiple class files (external files), yet am…
Simon
  • 7,991
  • 21
  • 83
  • 163
2
votes
1 answer

getting runtime error assembly 'System.Runtime' while using CSharpCodeProvider

I'm getting runtime error about missing reference. The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral,…
Neo
  • 15,491
  • 59
  • 215
  • 405
2
votes
1 answer

Compile Func from string on the fly

I have a string string input; with some code (all below is in that string) var x = s.IndexOf("a"); return String.Format(s, x); Now, I would like to achieve following scenario: Func f = Compile(input); var test = "dcba - {0}"; var…
Gerino
  • 1,943
  • 1
  • 16
  • 21
2
votes
3 answers

How to compile and execute a user defined formula dynamically (runtime) in c#?

I want to write a piece of code in c# which is able to compile and execute user defined formulas entered as string (valid c# code) in a windows form. Is there a simple and elegant way for doing this? As an example, see the method below: public…
tuncalik
  • 1,124
  • 1
  • 14
  • 20
2
votes
0 answers

CSharpCodeProvider throwing "'The process cannot access the file because it is being used by another process." on the same file it's generating

...and it's not because the file was there to begin with. I can prove it. The background is this: We have a desktop application which generate WORD/PDF documents. The document consist of Building blocks - small classes that produces a certain…
hannodb
  • 223
  • 1
  • 11
2
votes
0 answers

Assembly.GetTypes() after dynamic compilation works only once

(I'm having trouble finding an appropriate title for this) I am required to use a C# CodeDomProvider to compile several files containing a class each. I wrote a 'generator' class containing said provider (amongst other stuff) which is called to…
2
votes
1 answer

Slow dynamic compilation with CSharpCodeProvider

I was trying to compare dynamic compilation with standard compilcation. And dynamic compilation seems to be a lot slower. 1400% slower according to my benchmark. Here is the method that generates a delegate that calls a dynamically compiled…
Sergey
  • 47,222
  • 25
  • 87
  • 129
2
votes
3 answers

Releasing from memory the code generated by CSharpCodeProvider

I used CSharpCodeProvider to compile and generate a new namespace in the memory for temporary use only. But this namespace should be deleted from the memory after certain period of time in order to allow for the next generated code to override the…
David von Tamar
  • 797
  • 3
  • 12
  • 29
2
votes
2 answers

CSharpProvider runtime compilation failing to find a DLL

I am compiling a DLL at runtime using CSharpCodeProvider. My code runs fine on some machines but on otherse it fails with the following error: error CS0006: Metadata file 'EntityFramework.dll' could not be found Here is a code snippet: var csFile…
2
votes
2 answers

How to add reference to Outlook VSTO in a dynamic CSharpCodeProvider script

I am trying to use an xml file to determine which outlook properties be should be included in a workflow executed via VSTO addin code. Example The xml might state that the Subject of the current Outlook.MailItem is required by the workflow. I…
Visual Micro
  • 1,561
  • 13
  • 26
2
votes
1 answer

Scripts compiled at runtime fail to invoke method with optional arguments

We've added a feature for our users to write C# scripts for the application to execute, which are compiled and run at runtime. The scripts may access an API we've exposed, and they're compiled/run by CSharpCodeProvider. I find that the code…
wilee
  • 601
  • 2
  • 6
  • 19
1 2
3
10 11