給DNN裝SkinTuner擴展時出現Could not load file or assembly 'System.Data.SQLite

1、昨天晚上擺弄Dotnetnuke到四點,最後在裝一個SkinTuner的皮膚(調試)控制器時,出現嚴重錯誤致使沒法瀏覽管理網站:
 
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 
 
2、爲了查看詳細錯誤,用ftp工具將web.config下載下來修改 <customErrors mode="RemoteOnly" />爲 <customErrors mode="Off" />顯示以下詳細錯誤:
 
Unverifiable code failed policy check. (Exception from HRESULT: 0x80131402)
Stack Trace: 
[FileLoadException: Unverifiable code failed policy check. (Exception from HRESULT: 0x80131402)]
[FileLoadException: Could not load file or assembly 'System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. Unverifiable code failed policy check. (Exception from HRESULT: 0x80131402)]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +144
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46
[ConfigurationErrorsException: Could not load file or assembly 'System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. Unverifiable code failed policy check. (Exception from HRESULT: 0x80131402)]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +618
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +209
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +94
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +332
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +591
[HttpException (0x80004005): Could not load file or assembly 'System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. Unverifiable code failed policy check. (Exception from HRESULT: 0x80131402)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8946484
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256
 
3、能夠看出,根本緣由是 Could not load file or assembly 'System.Data.SQLite,能夠判定,最後安裝的SkinTuner使用的SQLite,查看安裝色發現果真有System.Data.SQLite.dll,在網站裏也找到了System.Data.SQLite.dll,但卻沒法加載,爲何呢?搜索ould not load file or assembly 'System.Data.SQLite找到答案,我正好用的godaddy.com的空間,這一錯誤是godaddy的限制形成的!
 
System.Data.SQLite.dll是沒法在godaddy的服務器上使用的。緣由是godaddy的ASP.NET2.0及以上的IIS使用了「信任級別」的限制:TrustLevel=」Medium」,也就是說,不少第三方的dll將無定法在這個級別下運行。必須把TrustLevel設置爲」Full」,纔可使用。可是出於安全考慮godaddy通常不會開發這個信任級別。 
爲何TrustLevel=」Medium」,就沒法使用System.Data.SQLite.dll,是由於當服務器設置了TrustLevel=」Medium」以後,要求運行的dll必須是「徹底託管代碼」(pure managed code),而且不能包含任何的 P/Invoke調用或使用任何的原始API(raw API)調用。不幸的是,System.Data.SQLite.dll使用了P/Invoke調用。因此沒法跑在TrustLevel=」Medium」級別下。
若是必定要使用SQLite數據庫的話,方法是有的:
一、使用ASP.NET1.1(固然這樣就無法使用不少東西,包括EF層面上的)
二、使用「託管代碼」(managed code)的Sqlite數據庫,這裏有一個可使用:http://code.google.com/p/managed-sqlite/
 
4、下載http://managed-sqlite.googlecode.com/svn/branches/bin/1.0.0.1340/ManagedSQLite.zip後更名爲System.Data.SQLite.dll,上傳到網站bin目錄下
結果出現以下錯誤:

Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Data.SQLite' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace: 
[FileLoadException: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +144
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46
[ConfigurationErrorsException: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +618
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +209
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +94
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +332
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +591
[HttpException (0x80004005): Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8946484
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256

 

5、The located assembly's manifest definition does not match the assembly reference 原來是版本不匹配形成的,版本設置或檢查是在哪裏進行的呢,是SkinTuner裏的文件設置的(搜索了全部安裝文件沒找到)仍是由dnn系統檢查的(如果,在哪裏我也不清楚,網上沒搜到)。

因而我有個想法:先想辦法使網站恢復正常-卸載SkinTuner-將SkinTuner.zip裏的System.Data.SQLite.dll替換成純託管代碼版的-再安裝,看看能不能自動識別版本以註冊。(有這些想法都是因爲對具體註冊機制不瞭解),結果仍是和上面的錯誤同樣,同校的方法,不過此次替換成官方最新版SQLite,此次沒有出錯(難道最新版已經使用徹底託管的代碼了?),可是在頁面上添加該模塊後,在模塊裏提示了版本不匹配的錯誤,難道要暴力修改SQLite不成,算了懶得弄了, SkinTuner倒底有多大用處都不清楚, 乾脆卸載了SkinTuner。
 
雖然沒有能成功運行SkinTuner,但起碼在實踐中解決了這種狀況下網站沒法訪問的問題,也許安裝其它擴展出現此類問題時可如法炮製。
 
相關文章
相關標籤/搜索