T4模板组装指令 [英] T4 template assembly directive

查看:303
本文介绍了T4模板组装指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的dll,其中有一类在里面,(为简单起见)有它的方法which'll返回一个字符串。

I have a custom dll, which has a class in it, and (for simplicity's sake) there's a method on it which'll return a string.

我有一个项目,它引用的DLL说,我想用一个(而不是preprocessed)T4模板在该项目中,它调用该方法。我试过这样的:

I have a project, which references said dll, and I want to use a (not preprocessed) T4 template in that project, which calls said method. I've tried this:

<#@ template debug="true" hostspecific="false" language="C#" #>
<#@ assembly name="MyDLL.dll" #>
<#@ output extension=".cs" #>
<#
    var template = new MyDLL.MyNamespace.MyClass();
        this.Write(template.Run());
#>

我得到了以下错误:

I got the following errors:

错误14 编译转型:元数据文件MYDLL.DLL找不到
  错误13 命名空间不能直接包含的成员,如字段或方法

Error 14 Compiling transformation: Metadata file 'MyDLL.dll' could not be found
Error 13 A namespace cannot directly contain members such as fields or methods

即使MyClass.Run()是一个简单的返回//你好;

even if MyClass.Run() is simply a return "//hello";

推荐答案

好像你的问题:

错误编译转型:元数据文件dotless.Core无法找到

Error Compiling transformation: Metadata file 'dotless.Core' could not be found

这是由于这里所描述的兼容性突破:

It's due to compatibility break described here:

<一个href="http://weblogs.asp.net/lhunt/archive/2010/05/04/t4-template-error-assembly-directive-cannot-locate-referenced-assembly-in-visual-studio-2010-project.aspx">http://weblogs.asp.net/lhunt/archive/2010/05/04/t4-template-error-assembly-directive-cannot-locate-referenced-assembly-in-visual-studio-2010-project.aspx

这篇关于T4模板组装指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆