compileassemblyfromsource

C# CompileAssemblyFromSource, add referenced assemblies it needs?

佐手、 提交于 2019-12-30 08:51:08
问题 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 blah and say it is missing a resource. So if it is "System.Windows.Forms", and I say "compilerparams.ReferencedAssemblies.Add("System.Windows.Forms.dll")", it works. So I can parse the code file and get all the "using" parameters, but how do I know

Prevent CompileAssemblyFromSource from generate temp files with duplicate file name

馋奶兔 提交于 2019-12-23 10:49:15
问题 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 being calculated the CSharpCodeProvider.CompileAssemblyFromSource generates temp files with duplicated name, what lead to a IOException ("The file 'C:\Windows\TEMP\uviewdyd.out' already exists.") Does anyone know how to prevent this? 回答1: I don't

“CompileAssemblyFromSource” in f# powerPack codeDom

大兔子大兔子 提交于 2019-12-10 14:43:40
问题 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 of just one function: unit -> string let codeString = "module Synthetic.Code\n let syntheticFunction() = \"I've been compiled on the fly!\"" // Assembly path to keep compiled code let synthAssemblyPath = "synthetic.dll" let CompileFSharpCode(codeString,

Possible to get native performance for dynamically compiled code that can be unloaded?

自闭症网瘾萝莉.ら 提交于 2019-12-08 10:50:47
问题 I have a function that uses a tree-like structure of dictionaries to match against incoming structures coming in at a rate of several 100k/sec. It is already quite fast, but it needs to get even faster. In order to gauge how much faster it would get by compiling that piece of code in the most performant way, I hard-coded an optimized function for a particular tree of dictionaries, using nested switch statements (in this case, switching over byte s), and compared that to the dictionary-style

Accessing class and function after compiling ( CompiledAssembly )

╄→尐↘猪︶ㄣ 提交于 2019-12-08 07:14:55
问题 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 static void test() { JScriptCodeProvider js = new JScriptCodeProvider(); System.CodeDom.Compiler.CompilerParameters param = new System.CodeDom.Compiler.CompilerParameters(); var cr = js.CompileAssemblyFromSource(param, new string[] { "package pkg {

C# CompileAssemblyFromSource, add referenced assemblies it needs?

百般思念 提交于 2019-12-01 04:17:44
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 blah and say it is missing a resource. So if it is "System.Windows.Forms", and I say "compilerparams.ReferencedAssemblies.Add("System.Windows.Forms.dll")", it works. So I can parse the code file and get all the "using" parameters, but how do I know that those are supposed to be "*.dll" adding, or they are namespaces elsewhere or whatnot? Is there a way

How can I prevent CompileAssemblyFromSource from leaking memory?

孤人 提交于 2019-11-27 03:24:26
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 a ASP.NET web app, but I've duplicated this problem in a WinForm. I'm using System.GC.GetTotalMemory(true) and Red Gate ANTS Memory Profiler to measure the growth (about 600 bytes with the sample code). From the searching I've done, it sounds like the leak comes from the creation of new types, not really from any objects that I'm holding references

How can I prevent CompileAssemblyFromSource from leaking memory?

岁酱吖の 提交于 2019-11-26 10:31:35
问题 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 a ASP.NET web app, but I\'ve duplicated this problem in a WinForm. I\'m using System.GC.GetTotalMemory(true) and Red Gate ANTS Memory Profiler to measure the growth (about 600 bytes with the sample code). From the searching I\'ve done, it sounds