0

Is there a way to compile files automatically in the right order. Seems like 'CompileAssemblyFromFile' do not care about dependencies before compiling. Way around ?

public bClass 
{
   public aClass FieldName; //Trows error not aClass type not found
}

Compile Order

1. bClass.css
2. aClass.cs
1
  • Show how you call the compiler. C# is multipass, it shouldn't matter. Commented Apr 22, 2014 at 17:57

1 Answer 1

4

It works for me in either order:

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;
}
Sign up to request clarification or add additional context in comments.

1 Comment

My mistake. Made a typo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.