jscript.net 코드를 실행하고 싶습니다. 일부 양식에 이벤트가있는 버튼이 있습니다. 모두 C#에서 리플렉션을 통해 수행해야하지만 이러한 이벤트로 적절한 예제를 찾을 수는 없습니다. 도움을 좀주세요. 내가 지금까지 가지고 있지만 당신은 당신이jscript.net 코드가 리플렉션을 사용하여 C#에서
내가 사용 jint를을 JS 통역 중 하나를 사용하는 것이 더 낫다 C#을 응용 프로그램에서 자바 스크립트를 실행하려는 경우 마지막 줄에 오류
StringBuilder sb = new StringBuilder();
sb.AppendLine("import System.Windows.Forms;");
sb.AppendLine("class EventTestForm extends Form");
sb.AppendLine("{");
sb.AppendLine(" var btn : Button;");
sb.AppendLine("function EventTestForm()");
sb.AppendLine("{");
sb.AppendLine(" btn = new Button; btn.Text = \"Fire Event\"; Controls.Add(btn); btn.add_Click(ButtonEventHandler1);");
sb.AppendLine("}");
sb.AppendLine("function ButtonEventHandler1(sender, e : EventArgs)");
sb.AppendLine("{");
sb.AppendLine(" MessageBox.Show(\"Event is Fired!\");");
sb.AppendLine("}");
sb.AppendLine("}");
sb.AppendLine("MessageBox.Show(\"Hello world\");");
// Create the compiler object
JScriptCodeProvider provider = new JScriptCodeProvider();
ICodeCompiler compiler = provider.CreateCompiler();
CompilerParameters options = new CompilerParameters();
options.GenerateInMemory = true;
options.GenerateExecutable = true;
options.ReferencedAssemblies.Add("System.Windows.Forms");
CompilerResults results = compiler.CompileAssemblyFromSource(options, sb.ToString());
을 사용 ??? – Liam
System.Reflection.Assembly._nLoad (AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark 및 stackMark, Boolean throwOnFileNotFound, Introspection의 부울) –
오류 메시지가 아 닙니까? 실행 중에 예외가 발생하거나 컴파일되지 않습니까? – Liam