2011-11-11 29 views
1

我試圖使用從大廈System.Data.SQLite,構建與目標框架4.0

http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

我能下載的源代碼來構建System.Data.SQLite在Visual Studio構建解決方案,但是當我試圖從TargetFramework = 3.5的項目中引用System.Data.SQLite.dll,我收到以下消息:

"System.Data.SQLite.dll or one of its dependencies, requires a later version of the .NET Framework than the one specified in the project."

我注意到,他們的管理項目(System.Data。 SQLite.2010,System.Data.SQLite.Linq.2010,和System.Data.SQLite.Module.2010)都設置爲以.NET 4.0爲目標。然後,我將它們全部改爲參考3.5,重建並再次嘗試。當時我能夠引用的項目,但是我收到一個新的運行時錯誤:

"Could not oad file or assembly 'System.Data.SQLite' or one of its dependencies. This assembly is build by a runtime newer than the currently loaded runtime and cannot be loaded."

我用ILDASM打開.dll文件,並清單確實說//元數據版本:v4.0.30319這並不讓道理給我,因爲他們的文件明確指出,它應該與.NET 2.0的工作:

".We want to ship managed binaries that rely on the .NET Framework 2.0 SP2 (or for the LINQ assembly, the .NET Framework 3.5 SP1). The .NET Framework 2.0 is very widely deployed and binaries produced for it can also be referenced and used successfully from projects using the .NET Framework 4.0. "

http://system.data.sqlite.org/index.html/doc/trunk/www/build.wiki

該解決方案是怎樣的一個噩夢,有很多定製的編譯選項的目標文件,並噸。我不太確定目標框架的設置位置。我猜想有一些魔法在某處發生。

有沒有人有任何建設這個項目的經驗?任何幫助,將不勝感激。謝謝!

+0

您使用了哪種下載解決方案?你是否試圖在3.5應用程序中使用.NET 4.0版本? –

+0

我看到下載的唯一代碼是http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki第一個鏈接:http://system.data.sqlite.org /sqlite-netFx-source-1.0.76.0.zip我正在使用SQLite.NET.2010.sln – Adam

回答

2

建設的關鍵在Visual Studio 2010中System.Data.SQLite解決方案針對V3.5知道VC++項目(SQLite.Interop.2010和SQLite.Interop.Static)默認是針對框架版本4.0的。當你在C#項目(System.Data.SQLite.2010和System.Data.SQLite.Linq.2010)上正確定位v3.5時,可能不清楚如何翻轉VC++項目的目標版本。

Microsoft提出的用於在VC++中更改框架版本的建議方法是從Visual Studio 2010中卸載該項目。然後分離出文本編輯器,在解決方案目錄中找到.vcxproj,然後插入TargetFrameworkVersion標籤,其值爲將「v3.5」添加到「Globals」PropertyGroup標記中。在Visual Studio 2010中重新加載項目之後,現在應該在項目屬性的「框架和參考」部分中看到version = 3.5。 Reference Link

對於System.Data.SQLite,您必須爲兩個VC++項目(SQLite.Interop.2010和SQLite.Interop.Static)執行此操作。注意:如果您嘗試將VC++項目定位到Visual Studio 2010中的框架版本3.5,則還需要安裝Visual Studio 2008 SP1(VC 9.0)。另外,如果你想在框架版本3.5的VC++ 2010中編譯x64,你需要在Visual Studio 2008 SP1(VC 9.0)中安裝x64編譯器和工具(默認情況下不安裝)。

重新編譯後,ILDASM應顯示「元數據版本:V2.0.50727」在艙單System.Data.SQLite.dll

我也注意到,在VS2010的解決方案翻到Framework 3.5版,有後由於作者在代碼中引用「屬性」資源(即Resources.resx)的方式,System.Data.SQLite.Linq.2010中出現了一些新的構建錯誤。

1

這可能是由使用VS2010構建的,我相信默認情況下使用的是ToolsVersion設置爲4.0。包含在該zip文件中的是VS2008的MSBuild解決方案文件(默認使用ToolsVersion爲3.5)。我懷疑使用MSBuild的.NET 3.5版本構建該解決方案文件將爲您提供一個與3.5版本兼容的DLL。

「C:\ WINDOWS \ Microsoft.NET \框架\ v3.5版本\ MSBuild.exe」 「」