VS2010 下T4引用程序集,未能找到元数据文件(xxx.dll could not be found)
VS2010 下 T4使用
<#@ assembly name="System.Data.SQLite.dll" #>
可以能出现下述错误
Error 3 Compiling transformation: 未能找到元数据文件“System.Data.SQLite.dll”
问题原因:
http://blogs.msdn.com/garethj/archive/2010/04/15/what-s-new-in-t4-in-visual-studio-2010.aspx
T4's assembly set is completely separated from the containing project's assembly set to avoid picking up the wrong assemblies when a project targets previous framework versions. Project assemblies are no longer used to resolve template assembly directives.
为了避免因为项目与模板在.net framework 版本不一致上引发程序集错误,T4 的程序集已经完全独立于所在项目的程序集。项目的程序集不再直接影响模板的程序集。
- GAC your assemblies and use Namespace Reference or Fully Qualified Type Name
- Use a hard-coded Fully Qualified UNC path
- Copy assembly to Visual Studio "Public Assemblies Folder" and use Namespace Reference or Fully Qualified Type Name.
注如:D:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies,拷进去之后需要重启vs2010.
- Use or Define a Windows Environment Variable to build a Fully Qualified UNC path.
- Use a Visual Studio Macro to build a Fully Qualified UNC path.