【问题标题】:How to add reference an assembly that is not in the GAC from a t4mvc template (.tt)如何从 t4mvc 模板 (.tt) 添加引用不在 GAC 中的程序集
【发布时间】:2010-05-12 13:48:56
【问题描述】:

我在 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 中的程序集的引用?

【问题讨论】:

    标签: asp.net-mvc gac t4mvc


    【解决方案1】:

    假设您使用的是 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

    【讨论】:

    • 似乎整个 weblogs.asp.net 现在都关闭了,包括像 weblogs.asp.net/scottgu 这样的主要网站。放松,我相信它会恢复的:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-09
    相关资源
    最近更新 更多