2013-10-29 4 views
1

그래서이 응용 프로그램을 만들면 Visual Studio Build를 사용하지 않고 Windows Form 응용 프로그램을 작성할 수 있습니다.CodeDom이 주 클래스를 연결하지 않습니다.

다른 클래스와 기본 클래스가 "Application.Run();"을 실행해야한다는 사실을 잊어 버리면 올바르게 작동합니다. 다른 반으로.

Could not find 'RunLauncher' specified for Main method 

I 스크립트의 몇 가지있다 :

내 문제는 다음 말한다이다. 첫 번째는 Windows Form C# 스크립트를 실행하는 Main 메서드가 포함 된 표준 C# 스크립트입니다. Application.Run() 메서드. 이 Windows Form C# Script에는 개체로 연결된 다른 클래스 (Load 메서드에서 생성됨)가 있으므로 총 3 개의 스크립트가 기본적으로 새 실행 파일로 컴파일되어야합니다.

Windows Form 응용 프로그램을 실행하기 위해 Application.Run() 메서드를 실행하는 기본 클래스 "RunLauncher"는 아래 나열된 Launcher 클래스를 실행합니다.

는 거의 긍정적 인 프로그래머에게 이러한 클래스를 컴파일하고 클래스를 찾아하지 않도록 실제 코드에 뭔가 문제가있어,하지만 의심의 이익을 위해, 어쨌든 그들을 연결 한 :

컴파일 된 CodeDom 코드 :

CSharpCodeProvider codeProvider = new CSharpCodeProvider(); 
ICodeCompiler icc = codeProvider.CreateCompiler(); 
string Output = game_filename.Text + ".exe"; 
Button ButtonObject = (Button)sender; 


System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters(); 
parameters.GenerateExecutable = true; 
parameters.OutputAssembly = Output; 

parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll"); 
parameters.ReferencedAssemblies.Add("System.dll"); 
parameters.ReferencedAssemblies.Add("System.IO.Compression.dll"); 
parameters.ReferencedAssemblies.Add("System.IO.Compression.FileSystem.dll"); 

if (codeProvider.Supports(GeneratorSupport.EntryPointMethod)) 
{ 
    parameters.MainClass = "RunLauncher"; 
} 

CodeCompileUnit compileUnits = new CodeCompileUnit(); 
CodeNamespace nsp = new CodeNamespace("kjpUnityGameLauncherTemplate"); 

compileUnits.Namespaces.Add(nsp); 
nsp.Imports.Add(new CodeNamespaceImport("kjpUnityGameLauncherTemplate")); 

CodeTypeDeclaration class1 = new CodeTypeDeclaration("RunLauncher"); 
nsp.Types.Add(class1); 

CodeTypeDeclaration class2 = new CodeTypeDeclaration("kjpUnityGameLauncher"); 
nsp.Types.Add(class2); 

CodeTypeDeclaration class3 = new CodeTypeDeclaration("Launcher"); 
nsp.Types.Add(class3); 

CompilerResults results = icc.CompileAssemblyFromDom(parameters, compileUnits); 
+0

대한 수정이 크게 당신이 요구 한 것을 변경하고 기존 답을 무효화 : 그 당신이 MainClass에서 설정해야 할 것을, 그래서 당신이 원하는 클래스는, kjpUnityGameLauncherTemplate.RunLauncher라고합니다. 그것은 스택 오버 플로우가 작동하는 방식이 아닙니다. 새로운 질문이있는 경우 [* 새 질문 *] (http://stackoverflow.com/questions/ask). – svick

+0

그 정도면 충분합니다. 새 질문을 만들었습니다. (이것과 거의 같은 목적으로), Stackoverflow가 작동하는 방식이라면 저는 그것을 바꾸지 않을 것입니다. 어쨌든 도움을 주셔서 감사합니다. –

답변

0

문제는 생성 된 어셈블리 RunLauncher라는 더 클래스가 없다는 것입니다. 질문에

parameters.MainClass = "kjpUnityGameLauncherTemplate.RunLauncher"; 
+0

그러나 위의 오류는 해결되었지만 지금도 비슷한 오류가 발생합니다. http://msdn.microsoft.com/en-us/library/y0bsx26d(v=vs.90).aspx –

관련 문제