Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you add an assembly reference programmatically?

I'm using the T4 TextTemplating service from a VSPackage:

var t4 = this.GetService(typeof(STextTemplating)) as ITextTemplating;

Normally if a template is referencing types in an external assembly you can use the assembly directive. However, I don't know the assembly until runtime, so is there anyway of adding assembly references to the T4 engine programmatically?

like image 736
devdigital Avatar asked Nov 08 '12 17:11

devdigital


1 Answers

I think the following may be a solution...

Write a custom host, see http://msdn.microsoft.com/en-us/library/bb126519.aspx

Before running the engine in that custom host, load the required assemblies using LoadFrom, see http://msdn.microsoft.com/en-us/library/1009fa28.aspx for details.

like image 93
Xyzzy Avatar answered Oct 22 '22 06:10

Xyzzy