第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從輸入字符串中釋放 .exe 文件作為代碼

從輸入字符串中釋放 .exe 文件作為代碼

C#
繁星點點滴滴 2022-11-21 22:03:42
我有個問題。如何釋放.exe文件string input?我想編譯成exe Hello World C#示例。這是我的代碼:var code = input.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);var provider = CodeDomProvider.CreateProvider("CSharp");string exeName = string.Format("test.exe", Environment.CurrentDirectory);var parameters = new CompilerParameters{    GenerateExecutable = true,    OutputAssembly = exeName,    GenerateInMemory = false,    TreatWarningsAsErrors = false};parameters.ReferencedAssemblies.Add("System.dll");var compilerResults = provider.CompileAssemblyFromSource(parameters, code);if (compilerResults.Errors.Count > 0)    //Errorelse    //Succes, file saved int Debug folder (exe file)從上面的代碼中,我想得到codeas string,然后我創(chuàng)建string[]數(shù)組(每個數(shù)組的記錄是下一行代碼)。然后,我想將該文件保存到exe文件Debug夾中。但是,現(xiàn)在,從compilerResults.Errors我得到的32錯誤看起來像這樣:我相信這與將此功能映射到c#語言有關。任何想法,我做錯了什么?
查看完整描述

1 回答

?
慕婉清6462132

TA貢獻1804條經(jīng)驗 獲得超2個贊

CodeDomProvider.CreateAssemblyFromSource期望數(shù)組中的每個字符串都是一個源文件——您為每個元素提供一行。

換句話說,您不需要先撥打電話Split。只需使用:

var code = new[] { input };


查看完整回答
反對 回復 2022-11-21
  • 1 回答
  • 0 關注
  • 95 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號