1
System.Reflection.Assembly.Load(System.IO.File.ReadAllBytes(path)) 

So this is a work around to not being able to use T4 to reflect or read other files in the project or solution without locking the binaries from this post. The comments imply a memory issue.

The comments talk about a no-unloading downside, would this be garbage collected while you are working?

would it be a memory leak if you T4 generate something using this code, change a file it worked off of or the T4 and then the T4 is re-run?

Community
  • 1
  • 1
Maslow
  • 18,464
  • 20
  • 106
  • 193

2 Answers2

2

It depends on the number and size of your assemblies. T4 recycles the code generation AppDomain after 25 runs, so it may not be a problem. More here: http://www.olegsych.com/2008/05/t4-architecture/

Oleg Sych
  • 6,548
  • 36
  • 34
0

I think that the best way of doing this is to make a shadow copy of the assembly

Thank you Muse VSExtensions

BALKANGraph
  • 2,031
  • 1
  • 15
  • 16