1

我在 T4MVC 模板文件 (.tt) 的最顶部附近找到了可以添加程序集引用的位置,如下所示:

<#@ assembly name="System.Core" #>  
<#@ import namespace="System.Collections.Generic" #>

但是,似乎我只能引用 GAC 中的程序集。即,如果我添加了一个程序集 MyProject.Stuff.dll(不在 GAC 中)作为对包含模板的 VS 项目的引用,那么我希望能够添加如下内容:

<#@ assembly name="MyProject.Stuff" #>
<#@ import namespace="MyProject.Stuff" #>

如果我这样做,那么我会收到以下错误:

错误 1 ​​编译转换:找不到元数据文件 'MyProject.Stuff' C:\Work\Development\DotNetSolution\MyProject\Utils\T4MVC\T4MVC.tt 1 1

如何添加对不在 GAC 中的程序集的引用?

4

1 回答 1

0

假设您使用的是 2010,这是因为加载行为发生了变化。以下博客文章解释了更改和解决方法:http ://weblogs.asp.net/lhunt/archive/2010/05/04/t4-template-error-assembly-directive-cannot-locate-referenced-assembly-in -visual-studio-2010-project.aspx

于 2010-05-14T22:58:05.727 回答