C# : dynamically get location of an assembly
2014, Jun 09
This time I’m posting just a simple tip (because my memory is sloppy, yeah):
I was playing a little bit with T4 templates and dynamic assembly generation and I needed to reference a couple of assembly included in my project. Unfortunately the adding a reference to the ReferencedAssemblies collection on a CompilerParameters instance requires the referenced assembly to be in the GAC or in the same output folder of the executing assembly.
A quick workaround I found is to just recover the reference local path using a contained type, something like this:
[csharp]
private static string GetAssemblyLocationByType
Et voilà!