简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM