有没有办法按正确的顺序自动编译文件。 看起来像'CompileAssemblyFromFile'并不关心依赖关系 在编译之前。四处走动?
public bClass
{
public aClass FieldName; //Trows error not aClass type not found
}
编译订单
1. bClass.css
2. aClass.cs
答案 0 :(得分:4)
它以任何顺序对我有用:
var pro = new CSharpCodeProvider();
var assem = pro.CompileAssemblyFromFile(new CompilerParameters(), "path/to/bClass.cs", "path/to/aClass.cs");
// or
var assem = pro.CompileAssemblyFromFile(new CompilerParameters(), "path/to/aClass.cs", "path/to/bClass.cs");
aClass.cs:
public class aClass
{
}
bClass.cs:
public class bClass
{
public aClass FieldName;
}