I'm making a small scripting engine in C# and I was wondering, is there some sort of #compiler directives or some sort of other header-like file I can compile with my script files to define what Managed Dlls my script files are referencing?
public static CompilerResults LoadScript(
string SourceCodeFile, string[] References)
{
var Parameters = new CompilerParameters()
{
GenerateExecutable = false,
GenerateInMemory = true,
IncludeDebugInformation = false,
};
Parameters.ReferencedAssemblies.AddRange(References);
return CSharpCodeProvider.CreateProvider(
CSharpCodeProvider.GetLanguageFromExtension(
Path.GetExtension(SourceCodeFile)))
.CompileAssemblyFromFile(Parameters, SourceCodeFile);
}
I would love to be able to eliminate this line of code:
Parameters.ReferencedAssemblies.AddRange(References);
and put that information in my scripts instead. The problem is I do not necessarily know ahead of time what .dlls the scripts are going to reference. My current solution right now is to parse a custom "script.cs.refs" file that looks something like this:"System.dll","System.Data.dll","SomeOther.dll","Ect.dll"
Any help on finding out where visual studio stores your references to dlls and if it has to be defined in a separate file, if there is a standardized format I should be using that I can load into the compiler that tells it this information, would be greatly appreciated!