Questions tagged [compileassemblyfromsource]

In .NET this method compiles an assembly from the specified array of strings containing source code, using the specified compiler settings.

14 questions
32
votes
4 answers

How can I prevent CompileAssemblyFromSource from leaking memory?

I have some C# code which is using CSharpCodeProvider.CompileAssemblyFromSource to create an assembly in memory. After the assembly has been garbage collected, my application uses more memory than it did before creating the assembly. My code is in…
Nogwater
  • 2,777
  • 3
  • 28
  • 28
7
votes
1 answer

C# CompileAssemblyFromSource, add referenced assemblies it needs?

I have the CompileAssemblyFromSource working for code that only references assemblies that my program (that compiles it) uses. It works beautifully. However, if I need to compile code that has a "using blah;" statement, it won't be able to find…
Nick
  • 739
  • 11
  • 22
5
votes
1 answer

.NET CompileAssemblyFromSource: Determine which source failed?

I'm dynamically compiling code, using the CompileAssemblyFromSource with multiple sources. In the event of a compile error I can retreive the line number etc. from the Errors collection. However the line number is the line number within all sources.…
5
votes
1 answer

Prevent CompileAssemblyFromSource from generate temp files with duplicate file name

My WCF application uses code compiled in run time to calculate some values of a report. I'm using CSharpCodeProvider.CompileAssemblyFromSource to compile the code. If the client (a Silverlight application) request a report while another report is…
Andre Nascentes
  • 391
  • 4
  • 14
5
votes
1 answer

"CompileAssemblyFromSource" in f# powerPack codeDom

I am trying to get going a basic program to dynamically compile and run f# code. I am trying to run the following code: open System open System.CodeDom.Compiler open Microsoft.FSharp.Compiler.CodeDom // Our (very simple) code string consisting…
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…
1
vote
1 answer

CompileAssemblyFromSource + Obfuscation = don't work

i have working CompileAssemblyFromSource code. But when i use any code protector like RedGate SmartAssembly or Themida it's stop working and i get error "Could not load file or assembly or one of its dependencies". Can you please help me with…
SLI
  • 713
  • 11
  • 29
1
vote
1 answer

Accessing class and function after compiling ( CompiledAssembly )

Heres some example code. I successfully figured out how to compile this. I grabbed the location and was able to use visual studios object browser to look through the DLL. I cant figure out how to get a class instance and call a function. public…
user34537
0
votes
1 answer

I can't change other Class var value with CompileAssemblyFromSource

i try to use CompileAssemblyFromSource to change 1 value at my main class. But when i compile i get error "Could not load file or assembly or one of its dependencies" and this only happens when i try change static value of other class. But if i…
SLI
  • 713
  • 11
  • 29
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

How to let CompileAssemblyFromSource() refer to user defined types in calling program

I'm successfully using dynamically compiled assemblies to evaluate user definable expressions at run time. My question is about how to pass references to the types defined in my own program into the CompileAssemblyFromSource() function. Currently…
0
votes
1 answer

CompileAssemblyFromSource test signs an assembly

I have a windows service written in C#. It dynamically generates C# code and compiles them to assemblies as abc.dll, xyz.dll etc. These assemblies are later loaded for execution. When compiling, I pass /keyfile: mykeyfile.snk" as one of the compiler…
0
votes
0 answers

How do I add an existing class to a DLL produced by CodeProvider.CompileAssemblyFromSource?

I am creating a dll using codeProvider.CompileAssemblyFromSource, and passing in my code as a string. I want the resultant dll to include another class that is already in my code and doesn't change. ie, instead of this line: compiledResults =…
mcmillab
  • 2,752
  • 2
  • 23
  • 37