![](/img/trans.png)
[英]How does one get rid of this design-time row in the DataGridView row at run-time?
[英]How does one run code within the browser at Run-time
我一直在這里使用文檔https://support.microsoft.com/en-gb/help/304655/how-to-programmatically-compile-code-using-c-compiler我試圖更多地了解編譯器我想在自己的網站上托管一個簡單的文本編輯器,我可以用它運行腳本代碼,例如
該程序需要打印出Console.WriteLine(“ Hello World”);。
如果打印出“ Hello World”以外的任何內容,則該程序將出錯。
我一直在查看在運行時運行.net代碼的Microsoft代碼,但是這些都迫使它創建一個exe,我希望結果像在文本框中顯示.net一樣。
我想我必須要做的是如何運行exe並使用該過程返回結果,但要記住這是在mvc應用程序內部。
還是他們可以節省我時間的任何酷小菜。
private void Compiler(string code)
{
CSharpCodeProvider codeProvider = new CSharpCodeProvider();
ICodeCompiler icc = codeProvider.CreateCompiler();
string Output = "Out.exe";
System.CodeDom.Compiler.CompilerParameters parameters = new
CompilerParameters();
//Make sure we generate an EXE, not a DLL
parameters.GenerateExecutable = true;
parameters.OutputAssembly = Output;
CompilerResults results = icc.CompileAssemblyFromSource(parameters, code);
if (results.Errors.Count > 0)
{
foreach (CompilerError CompErr in results.Errors)
{
CompilerError error = new CompilerError();
error.Line = CompErr.Line;
error.ErrorNumber = CompErr.ErrorNumber;
error.ErrorText = CompErr.ErrorText;
}
}
else
{
//Successful Compile
CodeResult result = new CodeResult();
result.Message = "Success";
}
}
因此,如何捕獲以上內容並返回,以及如何添加對其他語言(如python或vb.net)的支持
這是熾烈的人可能擅長為我做的事情嗎?
我想提供像.net小提琴這樣的體驗https://dotnetfiddle.net
Suchiman / Robin Sue在這個漂亮的blazor項目 ( 實時演示 )中集成了Monaco編輯器和瀏覽器內C#編譯器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.