我有一些 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 */
}
It is 过时的在 .NET Core 中,您可以使用 roslyn (github | nuget | docs) 反而。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)