The path to the .dll files was taken from here:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\
List<string> DLL = new List<string>(); //тут уже лежит список путей к .dll using (var provider = new CSharpCodeProvider()) { // DLL.ToArray() добавляю ссылки var Params = new CompilerParameters() { //parametrs build }; provider.CompileAssemblyFromSource(Params, SourceCode) // compile } But at compile time I get an error:
error CS1703: Multiple assemblies with the equivalent identity have been imported: 'C: \ Windows \ Microsoft .NET \ Framework \ v4.0.30319 \ mscorlib.dll' and 'C: \ Program Files (x86) \ Reference \ Assemblies \ Microsoft \ Framework .NETFramework \ v3.5 \ Profile \ Client \ mscorlib.dll '.
Remove one of the duplicate references.
How to fix?
[ Additional Information ]
The project itself is compiled under .Net4.5
(especially for Roslyn , he does not install his library for other versions of NetFramework )
If you take this code:
List<string> DLL = new List<string>() // просто файлы { "mscorlib.dll", "System.Data.dll" } using (var provider = new CSharpCodeProvider()) { var Params = new CompilerParameters(DLL.ToArray()) { //parametrs build }; provider.CompileAssemblyFromSource(Params, SourceCode) // compile } It all works, but it adds links from List<string> from the project itself (under which it was compiled) PS: Not from folders!
And I need to add from the folder I need, but if I do this (see 1st post), I get an error saying that you cannot add .dll libraries from different folders. How do I get the libraries I need and add them to the assembly I do not know how.
[ What did you do? ]
I tried to remove from the file that compiles links ( usings ).
I tried to remove the packages.config file
But all to no avail.
List<string> DLL. If I collect files from thev4.0framework, then everything works fine. (The project itself is compiled inNet v4.5). - LuserC:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dllstill picked up - Andrew NOP4.0I don’t know how to get rid of it. I basically need to somehow make it so that it collects links only from the necessary folder (using the example fromv3.5) and from the project build itself (under which it is compiled) - Luser