I’m writing a class library (say: lib) that parses and compiles Razor templates. The class library will be referenced in a project (say: proj) that contains the raw Razor templates.
The class library references a 3d party component (say: comp) which I am unable (licence-wise) to package within the library. This is not a problem because the proj will always contain the comp reference.
However inside lib I need to add the comp to the referenced assemblies:
var outputAssemblyName = Path.GetTempPath() + Guid.NewGuid().ToString("N") + ".dll";
CompilerParameters compilerParameters = new CompilerParameters(ReferencedAssemblies, outputAssemblyName);
compilerParameters.ReferencedAssemblies.Add("System.dll");
compilerParameters.ReferencedAssemblies.Add("System.Core.dll");
compilerParameters.ReferencedAssemblies.Add("3dpartycomp.dll"); //<<<<<<<<<<<<
The comp dll however isn’t found when it’s located in the /bin folder of the proj. Also the proj doesn’t have a /release folder because it is a website.
How do I add a reference to the 3d party component when it is located in the project hosting the library?
While adding reference, specify full path to your third party assemblies (like @”C:\App\bin\3rdpartycomp.dll”), as compiler only looks in framework directory (not even GAC) when a reference without path is specified. You may use Server.MapPath to get location of bin directory.