我有一个T4模板,我引用了一个不同的程序集:
var code = new CodeGenHelper();
然后我尝试在该dll中创建唯一类的实例:
Severity Code Description Project File Line Suppression State
Error Running transformation: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.VisualStudio.TextTemplatingCFC642B0A338D346F5BAF55401746E231DEE772554EE3570FFA3AA2898966BCA1378D2C2DC8325581610CA4D66B8A56C97E5C4A6AD35B2C18FAAAF37E1A6B7C9.GeneratedTextTransformation.TransformText()
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at Microsoft.VisualStudio.TextTemplating.TransformationRunner.PerformTransformation()
当我运行T4模板(又名,保存)时,我收到以下错误:
using System;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.CodeAnalysis.CSharp;
namespace Project.CodeGen
{
public class CodeGenHelper
{
public CodeGenHelper()
{
}
public string Derp(string herp)
{
... do stuff
}
}
}
然后我添加了对
的引用System.Runtime
(完全合格而不是),似乎都没有效果。
这就是Project.CodeGen源的样子(缩减):
<p-table #dt [value]="iToDoList" dataKey="ID" [paginator]="true" [rowsPerPageOptions]="[10,50,100]" [rows]="10">
<ng-template pTemplate="header">
<tr>
<th>ID</th>
<th>Comment</th>
<th>Action</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-row>
<tr>
<td>{{row.ID}}</td>
<td>
<div *ngIf="!row.isEditable">{{row.Comment}}</div>
<div *ngIf="row.isEditable">
<input type="text" [(ngModel)]="row.comment">
</div>
</td>
<td><button (click)="editRow(row)">Edit</button></td>
<td>
<button (click)="save(row)">Save</button>
</td>
</tr>
</ng-template>
</p-table>
我是否需要以某种方式引用System.Runtime,我认为核心无法进行?我需要引用像netstandard这样的东西吗?我很困惑,至少可以说。