在 .Net Core 中使用 CSharpCodeProvider。

5

我有一些使用C#编写的代码,根据SOAP WSDL和Swagger文档动态生成源代码,然后使用CSharpCodeProvider类的CompileAssemblyFromSource方法进行编译。在使用.Net 4.8时,这能够正常工作,但是当我尝试将其移植到.Net Core 3.0时,我现在会遇到以下错误:

"操作在此平台上不受支持。"

.Net Core是否支持此功能,或者是否可能很快添加支持?以下是一个简化的代码片段:

CSharpCodeProvider codeProvider = new CSharpCodeProvider();
string[] m_References = new string[] { "System.dll", "System.Core.dll", "System.Data.dll", "System.Net.dll", "System.Net.Http.dll", "System.Runtime.Serialization.dll", "System.ServiceModel.dll", "System.Xml.dll" };
CompilerParameters compilerParameters = CreateCompilerParameters(m_References);
m_CompilerResults = codeProvider.CompileAssemblyFromSource(compilerParameters, m_SourceStringArray);
if (!m_CompilerResults.Errors.HasErrors)
{
    /* render UI using compiled code */
}
else
{
    /* log compiler errors */
}
1个回答

10

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接