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

Dll referencing in CSharpCodeProvider only works when it's set to .NET 2.0?

When I set my CSharpCodeProvider class to use .NET 3.5 it errors trying to load certain referenced DLLs: Line number 0, Error Number: CS0006, 'Metadata file 'System.Linq.dll' could not be found; Line number 0, Error Number: CS0006, 'Metadata file…
Blam
  • 2,888
  • 3
  • 25
  • 39
1
vote
1 answer

Compiling Partial Classes with CSharpCodeProvider

I have a code template which builds files in a project's folder, and uses the properties defined in the partial classes to determine which properties still need to be implemented. As an example: public partial class Thingy : IThingy { public Foo…
CassOnMars
  • 6,153
  • 2
  • 32
  • 47
1
vote
1 answer

How to convert a matrix in a drawing.pointf

I need to draw the word "N" in a canvas, but the coordinates are in a matrix and i need to multiply that values, i try to draw the results with polygon and save in a array of points. how can i do that? so i need to do other operations with that…
1
vote
0 answers

CSharp Code Generator gives System.PlatformNotSupportedException

So I have this simple generator just for test purposes: var provider = new CSharpCodeProvider(); var options = new CompilerParameters { GenerateExecutable = false, GenerateInMemory = true }; …
Ahmed Fawzy
  • 309
  • 2
  • 8
1
vote
1 answer

C# CodeDomCompiler. error CS1056: Unexpected character '$'

My code is this: public static bool CompileClient(out string[] errors) { using (CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp")) { CompilerParameters cp = new CompilerParameters { …
Void
  • 45
  • 9
1
vote
1 answer

How to pass a variable with CSharpCodeProvider?

I need to create an EXE file with my application, I can pass strings with manipulating the string format but I cannot pass the other variables that I need to ex:byte array, here is my code if this helps: using Microsoft.CSharp; using System; using…
Antwns
  • 29
  • 7
1
vote
0 answers

Reference Assemblies imported by NuGet in Dynamic Compiler

I have some C# code that accepts a script written in C# itself and executes the script dynamically. I am able to make use of built in libraries by referencing their assemblies as shown below. CSharpCodeProvider provider = new…
webworm
  • 10,587
  • 33
  • 120
  • 217
1
vote
0 answers

Converting DataTable.Rows to List without knowing the column names and count

As input for this problem I have a DataTable instance. For some framework functions I have to use, I need to pass rows from this DataTable as List where properties of my_class are named like columns of the input DataTable. Maybe a better…
Monset
  • 648
  • 5
  • 25
1
vote
1 answer

How to unload assembly created by CSharpCodeProvider?

Problem CSharpCodeProvider can be used to compile source .cs files into an assembly. However, the assembly is automatically loaded into the AppDomain.CurrentDomain by default. In my case, this is a problem because I need to be able to re-compile the…
Ken
  • 89
  • 1
  • 8
1
vote
2 answers

DropDownList.SelectedItem.Text always is the first item in the DropDownList C#

I made a cascading dropdownlist. This is the first ddl :
J.Boy
  • 15
  • 4
1
vote
0 answers

Why does this code operate differently when compiled in Visual Studio vs LinqPad?

I am writing an application that needs to create a lot of folders. I ran into this stubborn error that I couldn't understand. I was getting DirectoryNotFoundException, which states in the exception message the exact string path that failed. I could…
OsakaRhymes
  • 96
  • 1
  • 8
1
vote
0 answers

How to improve compile time using CSharpCodeProvider

I have an application where user can create its own formula it works fine for all case but when i have DateTime Fields in my formula the compilation part of the code take around 132 ms for one formula where at the same time i have 31 formula each…
Mukesh Gupta
  • 59
  • 1
  • 7
1
vote
1 answer

C#: finding path to PresentationCore.dll (and other assemblies) in the GAC

I need to reference various assemblies in a CSharpCodeProvider via calling ReferencedAssemblies.Add. For some assemblies, it is sufficient to simply pass the assembly name - for example ReferencedAssemblies.Add("System.dll"). However,…
JDR
  • 1,094
  • 1
  • 11
  • 31
1
vote
0 answers

C# CSharpCodeProvider: executing method in "compiling assembly" without adding reference

I am using CSharpCodeProvider to compile C# into a dynamic assembly which contains methods that are called by an external software. Let's take the following code string that I am compiling dynamically: public static class Foo { public static…
JDR
  • 1,094
  • 1
  • 11
  • 31
1
vote
1 answer

C# two-dimensional array to validate entry in the form

There is a form that each user is required to complete, it has 4 fields: date, bill code, amount and currency. Bill code has a drop down menu with a lot of options of 4 that options are valid (Health, Travel, Meal, Hotel). Bill code field cannot be…