1

I have found the place near the very top in a T4MVC template file (.tt) where assembly references can be added, 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?

stephen
  • 1,200
  • 1
  • 13
  • 16

1 Answers1

0

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

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • Seems the whole weblogs.asp.net is down right now, including major ones like http://weblogs.asp.net/scottgu. Relax, I'm sure it'll come back up :) – David Ebbo Jun 11 '14 at 20:52