Let’s say I want to write a small program that we can give it a .CS file and it can compile it for us and say if there are any compilation erors or not. So I used CodeDom for this.
When I want to use CodeDOM I have to add the DLL names so that I can load them at run time.
something like this:
CompilerParameters parameters = new CompilerParameters();
parameters.ReferencedAssemblies.Add("System.dll");
parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll");
But there are some problems to this approach:
How can I make sure I have imcluded all the necessary DLLs?
Is it the only way? Are there better ways instead of adding these DLLs like this?
Thanks.
You don’t need to hard-code anything. Imagine calling
Add()in a loop, using DLL names that are read from a text file — or found in a directory at runtime, for that matter. You have all the tools you need to write something very flexible.