如何从 t4mvc 模板 (.tt) 添加引用不在 GAC 中的程序集

发布于 2024-09-01 18:51:28 字数 613 浏览 3 评论 0原文

我在 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

如何添加对不在其中的程序集的引用政府咨询委员会?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

稚然 2024-09-08 18:51:28

假设您使用的是 2010,这是因为加载行为已更改。以下博客文章解释了更改和解决方法: http://weblogs.asp.net/lhunt/archive/2010/05/04/t4-template-error- assembly -指令无法定位引用程序集-in-visual-studio-2010-project.aspx

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文