How to add reference an assembly that is not in the GAC from a t4mvc template (.tt)
I have found the place near the very top in a T4MVC template file (.tt) where assembly references can be add开发者_JS百科ed, which looks like:
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Collections.Generic" #>
However, it seems that I can only reference assemblies that are in the GAC. i.e. if I have an assembly MyProject.Stuff.dll (not in the GAC) added as a reference to the VS project containing the template then I expected to be able to add something like the following:
<#@ assembly name="MyProject.Stuff" #>
<#@ import namespace="MyProject.Stuff" #>
If I do this then I get the following error:
Error 1 Compiling transformation: Metadata file 'MyProject.Stuff' could not be found C:\Work\Development\DotNetSolution\MyProject\Utils\T4MVC\T4MVC.tt 1 1
How can I add a reference to an assembly that isn't in the GAC?
Assuming you are using 2010, this is because the loading behavior has changed. The following blog post explains the change and the workarounds: http://weblogs.asp.net/lhunt/archive/2010/05/04/t4-template-error-assembly-directive-cannot-locate-referenced-assembly-in-visual-studio-2010-project.aspx
精彩评论