能否动态创建类并继承泛型父类并编译 #229
Replies: 3 comments 3 replies
-
DataService是继承了ControllerBase,编译会报异常:NatashaException: 类型“ControllerBase”在未引用的程序集中定义。必须添加对程序集“Microsoft.AspNetCore.Mvc.Core, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60”的引用。 |
Beta Was this translation helpful? Give feedback.
1 reply
-
你所发的邮件已收到,查阅后再回复!
|
Beta Was this translation helpful? Give feedback.
0 replies
-
我想实现动态编译webapi接口程序集,builder.Add(DefaultUsing.UsingScript + code);的时候会异常提示:
NatashaException: 应输入标识符
AssemblyCSharpBuilder.Add(string script)
已引入包:
DotNetCore.Natasha.CSharp
DotNetCore.Compile.Environment
代码如下:
NatashaInitializer.Preheating((asmName, name) => {
if (name != null)
{
return false;
}
return true;
});
AssemblyCSharpBuilder builder = new();
builder.ConfigCompilerOption(item => item.AddSupperess("CS0108"));
builder.Domain = NatashaManagement.CreateRandomDomain();
builder.Add(DefaultUsing.UsingScript + @"public class A{}");
//获取编译后的动态程序集
var assembly = builder.GetAssembly();
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
public class FrontendApiService : DataService<IFrontendApiBLL, Dictionary<string, object>>{}
Beta Was this translation helpful? Give feedback.
All reactions