我使用的是我在6个月前上次使用的现有T4模板,我不知道有任何改变。 但是,当我保存模板文件时,我没有得到以下异常:
初始化转换对象时生成错误。 转换不会运行。 抛出以下异常:System.IO.FileNotFoundException:无法加载文件或程序集'T4Toolbox,Version = 11.0.0.0,Culture = neutral,PublicKeyToken = dc4a538672a7b38f'或其依赖项之一。 该系统找不到指定的文件。 文件名:' T4Toolbox,Version = 11.0.0.0 ,Culture = neutral,PublicKeyToken = dc4a538672a7b38f'
服务器堆栈跟踪:在System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)...
我的tt文件的标题是:
<#@ template language="C#" debug="True" #> <#@ output extension="cs" #> <#@ include file="T4Toolbox.tt" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.IO" #> <#@ assembly name="System.Xml"#> <#@ assembly name="System.Linq"#> <#@ assembly name="$(TargetPath)" #> <#@ import namespace="System.Xml" #> <#@ import namespace="System.Diagnostics" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Collections.ObjectModel" #> <#@ import namespace="MyNamespace" #> <#@ parameter name="className" type="System.String" #>我检查了工具>扩展和更新,我安装了版本11.8.0.0。
还有什么我可以检查的吗?
I am using an existing T4 Template that I last used about 6 months ago and I'm not aware of anything having changed. However I am not getting the following exception, when I save the template file:
Errors were generated when initializing the transformation object. The transformation will not be run. The following Exception was thrown: System.IO.FileNotFoundException: Could not load file or assembly 'T4Toolbox, Version=11.0.0.0, Culture=neutral, PublicKeyToken=dc4a538672a7b38f' or one of its dependencies. The system cannot find the file specified. File name: 'T4Toolbox, Version=11.0.0.0, Culture=neutral, PublicKeyToken=dc4a538672a7b38f'
Server stack trace: at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) ...
The header for my tt file is:
<#@ template language="C#" debug="True" #> <#@ output extension="cs" #> <#@ include file="T4Toolbox.tt" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.IO" #> <#@ assembly name="System.Xml"#> <#@ assembly name="System.Linq"#> <#@ assembly name="$(TargetPath)" #> <#@ import namespace="System.Xml" #> <#@ import namespace="System.Diagnostics" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Collections.ObjectModel" #> <#@ import namespace="MyNamespace" #> <#@ parameter name="className" type="System.String" #>I have checked Tools > Extension and Updates and I have Version 11.8.0.0 installed.
Is there anything else I can check?
最满意答案
好的,所以我发现了发生了什么。 似乎T4 Toolbox对通过Visual Studio安装T4 Toolbox Extension的帐户敏感。
在我们的开发环境中,我们使用两个用户帐户进行开发,一个具有提升权限。 似乎T4 Toolbox Extension是使用一个帐户安装的,我试图将其与其他帐户一起使用。
因此,只要对遇到此问题的其他人发出警告,请确保使用正确的帐户安装Extension,因为扩展程序无法在多个帐户中运行,即使它显示为已正确安装。
或者像我一样做并卸载它。 然后使用所需的帐户安装它。
OK, so I found out what was going on. It seems that T4 Toolbox is sensitive to which account installed the T4 Toolbox Extension through Visual Studio.
In our development environment we use two user accounts for development, one with elevate privileges. It seems the T4 Toolbox Extension was installed using one account and I was trying to use it with the other account.
So just a word of warning for anyone else who encountered this problem, ensure that the Extension was installed with the correct account, as the extension won't work across multiple accounts, even though it is shown as correctly installed.
Or alternatively do as I did and uninstall it. Then install it using the desired account.
更多推荐
发布评论