我想开发一个.tt模板来从SQLite数据库中生成POCOs。
我使用SharpDevelop 4.4。
这是我目前拥有的.tt ..。
<#@ template hostspecific="true" language="C#" #>
<#@ output extension=".txt" #>
<#@ assembly name="System.Data" #>
<#@ assembly name="System.Data.SQLite" #>
<#@ import namespace="System.Data" #>
<#@ import namespace="System.Data.SQLite" #>
<#@ import namespace="System.IO" #>
<#
using (SQLiteConnection db =
new SQLiteConnection
(string.Format("Data Source={0}",
Path.Combine(Path.GetDirectoryName(Host.TemplateFile),
"Test.db"))))
{
db.Open();
}
#>
我将System.Data.SQLite.1.0.92.0 NuGet包添加到我的项目中,以便使SQLite工作。
当我运行我的模板时,我有以下错误:
Error running transform: System.DllNotFoundException: Unable to load DLL 'SQLite.Interop.dll': Le module spécifié est introuvable. (Exception from HRESULT: 0x8007007E)
at System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum op)
at System.Data.SQLite.SQLite3.StaticIsInitialized()
at System.Data.SQLite.SQLiteLog.Initialize()
at System.Data.SQLite.SQLiteConnection..ctor(String connectionString, Boolean parseViaFramework)
at System.Data.SQLite.SQLiteConnection..ctor(String connectionString)
at Microsoft.VisualStudio.TextTemplating.GeneratedTextTransformation5e95cd16.TransformText()
at Mono.TextTemplating.CompiledTemplate.Process()
抱歉法语留言..。"Le模块spécifiéest introuvable“意为”找不到指定的模块“。
看起来SharpDevelop设法从我的项目中找到了System.Data.SQLite.dll文件,但是没有找到它的本机对应SQLite.Interop.dll.
如何使SharpDevelop找到DLL?
有什么想法吗?
一旦我知道如何使SharpDevelop找到DLL并连接到我的数据库,模板的其余部分应该非常直接地实现.
谢谢你的帮助!
吉尼斯
发布于 2014-04-18 09:47:12
多亏了马特沃德的输入,我终于明白了这一点!
我使用进程监视器来查找SharpDevelop在哪里查找DLL。我发现的是..。
C:\Users\ghigad\Projets\CS\TestT4\packages\System.Data.SQLite.Core.1.0.92.0\lib\net40\x86\SQLite.Interop.dll
C:\Users\ghigad\Projets\CS\TestT4\packages\System.Data.SQLite.Core.1.0.92.0\lib\net40\Win32\SQLite.Interop.dll
C:\Program Files (x86)\SharpDevelop\4.4\AddIns\Misc\TextTemplating\x86\SQLite.Interop.dll
C:\Program Files (x86)\SharpDevelop\4.4\AddIns\Misc\TextTemplating\Win32\SQLite.Interop.dll
C:\Program Files (x86)\SharpDevelop\4.4\ADDINS\MISC\TEXTTEMPLATING\SQLite.Interop.dll
C:\Program Files (x86)\SharpDevelop\4.4\AddIns\Misc\TextTemplating\x86\SQLite.Interop.dll
C:\Program Files (x86)\SharpDevelop\4.4\AddIns\Misc\TextTemplating\Win32\SQLite.Interop.dll
C:\Users\ghigad\Projets\CS\TestT4\packages\System.Data.SQLite.Core.1.0.92.0\lib\net40\x86\SQLite.Interop.dll
C:\Users\ghigad\Projets\CS\TestT4\packages\System.Data.SQLite.Core.1.0.92.0\lib\net40\Win32\SQLite.Interop.dll
C:\Program Files (x86)\SharpDevelop\4.4\AddIns\Misc\TextTemplating\x86\SQLite.Interop.dll
C:\Program Files (x86)\SharpDevelop\4.4\AddIns\Misc\TextTemplating\Win32\SQLite.Interop.dll
C:\Program Files (x86)\SharpDevelop\4.4\ADDINS\MISC\TEXTTEMPLATING\SQLite.Interop.dll
C:\Program Files (x86)\SharpDevelop\4.4\AddIns\Misc\TextTemplating\x86\SQLite.Interop.dll
C:\Program Files (x86)\SharpDevelop\4.4\AddIns\Misc\TextTemplating\Win32\SQLite.Interop.dll
C:\Users\ghigad\Projets\CS\TestT4\packages\System.Data.SQLite.Core.1.0.92.0\lib\net40\SQLite.Interop.dll
C:\Program Files (x86)\SharpDevelop\4.4\bin\SQLite.Interop.dll
C:\Windows\SYSWOW64\SQLite.Interop.dll
C:\Windows\system\SQLite.Interop.dll
C:\Windows\SQLite.Interop.dll
C:\Windows\SYSWOW64\SQLite.Interop.dll
C:\Program Files\Common Files\Microsoft Shared\Windows Live\SQLite.Interop.dll
C:\Program Files (x86)\COMMON FILES\MICROSOFT SHARED\Windows Live\SQLite.Interop.dll
C:\Program Files\Java\jdk1.6.0_30\bin\SQLite.Interop.dll
C:\Program Files\apache-ant-1.8.2\bin\SQLite.Interop.dll
C:\cygwin\bin\SQLite.Interop.dll
C:\Windows\SYSWOW64\SQLite.Interop.dll
C:\Windows\SQLite.Interop.dll
C:\Windows\SYSWOW64\wbem\SQLite.Interop.dll
C:\Windows\SYSWOW64\WindowsPowerShell\v1.0\SQLite.Interop.dll
C:\Program Files\Intel\WiFi\bin\SQLite.Interop.dll
C:\Program Files\Common Files\Intel\WirelessCommon\SQLite.Interop.dll
C:\Program Files (x86)\COMMON FILES\Roxio Shared\DLLShared\SQLite.Interop.dll
C:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\SQLite.Interop.dll
C:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\SQLite.Interop.dll
C:\Program Files (x86)\COMMON FILES\Roxio Shared\OEM\12.0\DLLShared\SQLite.Interop.dll
C:\Program Files (x86)\Roxio\OEM\AudioCore\SQLite.Interop.dll
C:\Program Files (x86)\MICROSOFT SQL SERVER\100\Tools\Binn\SQLite.Interop.dll
C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLite.Interop.dll
C:\Program Files\Microsoft SQL Server\100\DTS\Binn\SQLite.Interop.dll
C:\Program Files (x86)\MICROSOFT SQL SERVER\100\Tools\Binn\VSShell\Common7\IDE\SQLite.Interop.dll
C:\Program Files (x86)\MICROSOFT SQL SERVER\100\DTS\Binn\SQLite.Interop.dll
C:\Program Files\TortoiseSVN\bin\SQLite.Interop.dll
C:\Program Files (x86)\QuickTime\QTSystem\SQLite.Interop.dll
C:\Program Files (x86)\Windows Live\Shared\SQLite.Interop.dll
因此,结果是搜索了相当多的目录,然后使用my PATH变量的内容搜索文件.
Matt将dll放在SharpDe信封的bin目录中的想法是可行的,但我不喜欢将文件保存在应用程序的目录中.这意味着如果我将SharpDevelop更新到一个更新的版本,我将不得不再次复制这些文件.
从日志中,我猜将dll从./packages/content/net40 40/x86复制到./packages/lib/net40 40/x86也会起到这个作用.这里同样的事情..。如果我玩弄SQLite的Nuget包目录结构,每次我从源代码管理或升级到更新版本时,我都必须再次复制该文件.
最后,我决定将DLL复制到C:\Program (x86)中的一个目录中,并将其添加到PATH中。
效果很好!
谢谢马特让我走上正轨!
发布于 2014-04-18 03:37:44
SharpDevelop将找到您的System.Data.SQLite.dll,因为您的项目将有它的引用。
我最初的想法是:
对于SQLite.Interop.dll,可以在项目中添加对其的引用,或者如果不想这样做,可以指定.dll的路径。你应该能够做这样的事情:
<#@ assembly name="$(SolutionDir)packages\System.Data.SQLite.Core.1.0.92.0\content\net45\x86\SQLite.Interop.dll" #>
不幸的是,这将无法工作,因为SQLite.Interop.dll不是.NET程序集。因此,解决方法/黑客是通过将SQLite.Interop.dll放在路径上,从而使SharpDevelop可以使用它。最简单的方法是将其复制到SharpDe信封的bin文件夹中:
C:\Program Files (x86)\SharpDevelop\4.4\bin
https://stackoverflow.com/questions/23146198
复制相似问题