2017-08-03 1 views
0

Nous avons 3 projets:Impossible de charger le fichier ou l'assembly 'DocumentDB.Spatial.Sql.dll' ou une de ses dépendances

  • Class Library (Framework cible 4.5)
  • Web App (MVC) Project (Framework 4.5 cible)
  • API Web Project (Framework cible 4.5.2)

récemment commencé à travailler avec Azure (pilote document DB) Cosmos DB. Toute l'implémentation est effectuée dans la bibliothèque de classes utilisée dans les projets API Web &.

Apparemment, Web App fonctionne très bien, mais projet REST api renvoie une erreur:

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

Maintenant, ont essayé les correctifs suivants (sans succès):

  1. Modifié l'API Target Framework à 4.5, redémarré - toujours la même erreur.
  2. Nettoyer la solution, reconstruire - toujours la même erreur
  3. La DLL DocumentDb.Spatial.Sql.dll est identique dans le projet Web Web & Web API.

Répondre

1

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

Ce chemin est suspect. Vous devez vérifier quel module essaie de charger cette DLL (et pourquoi)

Essayez d'activer la journalisation des liaisons d'assemblage et vérifiez les erreurs pendant le chargement de la solution. Pour activer la journalisation coller ce au fichier txt (et l'extension de changement à .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" 

Après cela, vérifiez le dossier C: \ FusionLog et rechercher ce DocumentDB.Spatial.Sql.dll dll)

+0

I avait modifié le chemin du fichier avant de poster la question. donc le chemin serait comme D: \ API \ bin \ DocumentDB.Spatial.sql.dll. désolé d'induire en erreur, mettra également à jour la question. Néanmoins, essayé le fichier d'édition reg et toutes les entrées sont mises à jour dans le registre, mais il n'y a pas de journal disponible. – Vikram

+0

Désolé, j'ai oublié d'ajouter, qu'après avoir créé ce fichier reg - vous devez double-cliquer dessus et permettre d'entrer dans la modification du registre. Vous l'avez fait? – Piotr

+0

oui, avait déjà fait cela et enfin il a commencé à capturer l'information. LOG: le téléchargement de l'assembly a réussi. Tentative d'installation du fichier: D: \ API \ bin \ DocumentDB.Spatial.Sql.dll JOURNAL: Début de la phase de configuration du cache de téléchargement. ERR: Erreur lors de l'extraction de l'importation manifeste à partir du fichier (hr = 0x80131018). ERR: Le programme d'installation a échoué avec hr = 0x80131018. ERR: Impossible de terminer l'installation de l'assembly (hr = 0x80131018). Sondage terminé. *** Entrée du journal du classeur d'assemblage (8/4/2017 @ 9:20:43 AM) *** L'opération a échoué. Résultat de liaison: hr = 0x80131018. Pas de description disponible. – Vikram