디스크의 다른 폴더에있는 .cs 프로그램을 컴파일하고 다른 프로그램을 사용하여 .dll 파일을 생성하고 싶습니다. cs 프로그램 또는 콘솔 응용 프로그램 또는 창 응용 프로그램. 당신이 뭔가 콘크리트 당신은 CS 파일에에서이 호출 할 수 있습니다다른 .cs 프로그램에서 디스크의 다른 폴더에있는 .cs 파일을 컴파일하십시오.
Process processCS= new Process();
processCS.StartInfo.WorkingDirectory = @"C:\<your code directory>";
processCS.StartInfo.FileName = @"C:\Windows\Microsoft .NET\Framework\version\csc.exe /out:yourdllname.dll yourcodefilename.cs";
processCS.StartInfo.CreateNoWindow = true;
processCS.Start();
processCS.WaitForExit();
이 다른 CS 파일을 컴파일하려고 찾을 수없는 때까지 나는이 같은 아이디어 뭔가를 다음
using (StreamReader textReader = new StreamReader(@"path\Filename.cs"))
{
textFile = textReader.ReadToEnd();
Console.WriteLine(textFile);
}
CodeDomProvider codeProvider = new CSharpCodeProvider();
ICodeCompiler compiler = codeProvider.CreateCompiler();
// add compiler parameters
CompilerParameters compilerParams = new CompilerParameters();
compilerParams.CompilerOptions = "/target:library /optimize";
compilerParams.GenerateExecutable = false;
compilerParams.GenerateInMemory = true;
compilerParams.IncludeDebugInformation = false;
compilerParams.ReferencedAssemblies.Add("mscorlib.dll");
compilerParams.ReferencedAssemblies.Add("System.dll");
// compile the code
CompilerResults results = compiler.CompileAssemblyFromSource(compilerParams, textFile);
무엇이 문제입니까? –
여러분은 여기에서 모든 편집 작업을하면서 정말 엉망이되었습니다. –
간단히 말해 C#에서'.cs' 파일을 컴파일하고 싶습니까? 그래서 작동하지 않는 것은 무엇입니까? –