t4 Debuging:ReflectionTypeLoadException“无法加载一个或多个请求的类型”

时间:2015-08-19 17:36:48

标签: visual-studio-2015 t4

我有自定义T4模板。当我右键单击并选择“运行自定义工具”时,它运行没有错误。如果我右键单击并选择“Debug T4 Template”,我会在上面添加

时收到错误
=== Pre-bind state information ===
LOG: DisplayName = My.Interfaces, Version=1.0.5708.24057, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/My.Interfaces.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/My.Interfaces/My.Interfaces.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/My.Interfaces.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/My.Interfaces/My.Interfaces.EXE.

我正在使用'Assembly'指令,其中包含从c:...到dll的完全限定的有效路径。

<#@ Assembly Name="C:\...\MY.Interfaces.dll" #>

再次调试时没有错误。

我的问题是如何让调试器正确导入程序集而不将其复制到'IDE'目录?

1 个答案:

答案 0 :(得分:0)

似乎我引用的dll是错误的版本。它位于同一解决方案中的项目的bin目录中。我更新了dll并重建了该项目。然后它工作,没有必要把DLL放在其他地方。

:\