Is it possible to compile a cs file during run time so I can access it like a normal class?
In practice I read out a text file and store its information in a class structure. Afterwards I need to access class members within my application.
What I did by now: I compiled the cs file and created a dll using this example
http://msdn.microsoft.com/en-us/library/system.codedom.compiler.compilerparameters.generateexecutable.aspx
I changed it to:
String exeName = String.Format(@"{0}\{1}.dll",
System.Environment.CurrentDirectory,
sourceFile.Name.Replace(".", "_"));
cp.GenerateExecutable = false;
cp.OutputAssembly = Name;
cp.GenerateInMemory = true;
cp.TreatWarningsAsErrors = false;
So what now?
edit:
will this help me:
[DllImport("srec_struct_cs.dll", SetLastError = true)]
Now you can load the assembly using one of the AppDomain.Load overloads.