2017-08-03 121 views
0

之一,我們有3個項目:無法加載文件或程序集 'DocumentDB.Spatial.Sql.dll' 或其依賴

  • 類庫(目標框架4.5)
  • Web應用程序(MVC)項目(目標框架4.5)
  • 的Web API項目(目標框架4.5.2)

最近開始Azure的宇宙DB(文件DB驅動程序)工作。所有的實現都是在API & Web App項目中使用的類庫中完成的。

顯然,Web應用程序工作正常,但REST API項目拋出一個錯誤:

Could not load file or assembly 'file:///API\bin\DocumentDB.Spatial.Sql.dll' or one of its dependencies. The module was expected to contain an assembly manifest. 
 

 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
 

 
Exception Details: System.BadImageFormatException: Could not load file or assembly 'file:///D:\API\bin\DocumentDB.Spatial.Sql.dll' or one of its dependencies. The module was expected to contain an assembly manifest. 
 

 
Source Error: 
 

 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 
 

 
Assembly Load Trace: The following information can be helpful to determine why the assembly 'file:///D:\API\bin\DocumentDB.Spatial.Sql.dll' 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: 
 

 

 
[BadImageFormatException: Could not load file or assembly 'file:///D:\API\bin\DocumentDB.Spatial.Sql.dll' or one of its dependencies. The module was expected to contain an assembly manifest.] 
 
    System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0 
 
    System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36 
 
    System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152 
 
    System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) +102 
 
    System.Reflection.Assembly.LoadFrom(String assemblyFile) +34 
 
    WebActivator.PreApplicationStartCode.Start() in D:\Code\Bitbucket\WebActivator\WebActivator\PreApplicationStartCode.cs:11 
 

 
[InvalidOperationException: The pre-application start initialization method Start on type WebActivator.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'file:///D:\API\bin\DocumentDB.Spatial.Sql.dll' or one of its dependencies. The module was expected to contain an assembly manifest..] 
 
    System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +613 
 
    System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +141 
 
    System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102 
 
    System.Web.Compilation.BuildManager.ExecutePreAppStart() +157 
 
    System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531 
 

 
[HttpException (0x80004005): The pre-application start initialization method Start on type WebActivator.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'file:///D:\API\bin\DocumentDB.Spatial.Sql.dll' or one of its dependencies. The module was expected to contain an assembly manifest..] 
 
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9942412 
 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +90 
 
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261

現在,已經嘗試了以下修訂(沒有成功):

  1. 將API目標框架更改爲4.5,重新啓動 - 仍然是相同的錯誤。
  2. 清理解決方案,重建 - 仍然是相同的錯誤
  3. dll DocumentDb.Spatial.Sql.dll是相同的Web應用程序& Web API項目。

回答

1

Could not load file or assembly 'file:///API\bin\DocumentDB.Spatial.Sql.dll'

此路徑是可疑的。您必須檢查哪個模塊試圖加載此dll(以及爲什麼)

嘗試啓用程序集綁定日誌記錄並在加載解決方案時檢查錯誤。要啓用日誌記錄本粘貼到txt文件(和更改擴展名爲.reg):

Windows Registry Editor Version 5.00 

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion] 
"ForceLog"=dword:00000001 
"LogFailures"=dword:00000001 
"LogResourceBinds"=dword:00000001 
"LogPath"="C:\\FusionLog" 

之後,支票夾C:\ FusionLog和搜索該DLL DocumentDB.Spatial.Sql.dll)

+0

我在發佈問題之前編輯了文件路徑。所以路徑就像D:\ API \ bin \ DocumentDB.Spatial.sql.dll。抱歉誤導,也會更新這個問題。 儘管如此,嘗試了reg編輯文件,所有條目也在註冊表中更新,但是沒有可用的日誌。 – Vikram

+0

對不起,我忘了補充一點,創建這個reg文件後 - 你必須雙擊它並允許輸入註冊表修改。你做到了嗎? – Piotr

+0

是的,已經這樣做了,最後它開始捕獲信息。 日誌:大會下載成功。嘗試安裝文件:D:\ API \ bin \ DocumentDB.Spatial.Sql.dll 日誌:進入下載緩存設置階段。 ERR:從文件中提取清單導入時出錯(hr = 0x80131018)。 錯誤:安裝失敗,hr = 0x80131018。 ERR:無法完成程序集的設置(hr = 0x80131018)。探測終止。 ***裝訂文件夾日誌條目(2017/8/4 @ 9:20:43 AM)*** 操作失敗。 綁定結果:hr = 0x80131018。沒有可用的描述。 – Vikram

相關問題