开发者

What are the ramifications of using System.Reflection.Assembly.Load(System.IO.File.ReadAllBytes(path)) in T4?

开发者 https://www.devze.com 2022-12-25 22:03 出处:网络
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 with
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?


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/


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

Thank you Muse VSExtensions

0

精彩评论

暂无评论...
验证码 换一张
取 消