J'utilise VS 2015 Update 2 avec Resharper Ultimate 2016.1 et j'ai ce problème bizarre.Assembly.LoadFrom ne charge pas la DLL à partir de bin debug lors de l'exécution des tests unitaires avec resharper
J'ai un projet de test appelé Test qui fait référence à deux projets, Model et Persistence. Le projet de modèle contient des classes d'entités nhibernate et le projet Persistence contient des fichiers * .hbm.xml. Ils ont été générés avec llblgenpro 4.2. J'utilise nhibernate 4.0.4.
Je NHibernate avec cet initialise appel:
NHibernateSession.Init(
new SimpleSessionStorage(),
new string[] { "Persistence.dll", "Model.dll" });
Quand je lance un de mes cas de test l'initialisation NHibernate échoue avec cette exception:
System.IO.FileNotFoundException was unhandled by user code
FileName=file:///C:\Users\costa\AppData\Local\JetBrains\Installations\ReSharperPlatformVs14\Persistence.dll
FusionLog==== Pre-bind state information ===
LOG: Where-ref bind. Location = C:\Users\costa\AppData\Local\JetBrains\Installations\ReSharperPlatformVs14\Persistence.dll
LOG: Appbase = file:///C:/projects/csharp/Test/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Users\costa\AppData\Local\Temp\s0hjyhsk.jq1\a3514fde-acb9-4c62-a0ce-a586f8202f35.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///C:/Users/costa/AppData/Local/JetBrains/Installations/ReSharperPlatformVs14/Persistence.dll.
HResult=-2147024894
Message=Could not load file or assembly 'file:///C:\Users\costa\AppData\Local\JetBrains\Installations\ReSharperPlatformVs14\Persistence.dll' or one of its dependencies. The system cannot find the file specified.
Source=mscorlib
StackTrace:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at SharpArch.NHibernate.NHibernateSession.<>c__DisplayClass36_0.<CreateSessionFactoryFor>b__0(MappingConfiguration m) in C:\work\sharp-arch\Solutions\SharpArch.NHibernate\NHibernateSession.cs:line 412
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
InnerException:
Si je copie le persistence.dll au C: \ Utilisateurs \ costa \ AppData \ Local \ JetBrains \ Installations \ ReSharperPlatformVs14 dossier, le cas de test fonctionne correctement. persistence.dll se trouve dans le dossier C:/projects/csharp/Test/bin/Debug car le projet de persistance est référencé dans le projet de test.
Tout a bien fonctionné dans VS 2013 avec nhibernate 3.3.1. J'ai également obtenu toutes les versions dll à aligner en utilisant les éléments assemblybinding dans le fichier app.config de projet de test.
Mes projets ciblent .Net 4.6 et j'utilise nunit 3.2.1.
Je trouve ceci:
Resharper runs UnitTest from different location
Cependant, dans mon cas « ensembles de clichés instantanés à l'essai » est désactivé, utilisez AppDomain pour chaque assemblage avec des tests est également désactivé. Exécuter les tests à partir de est défini sur le dossier de sortie du projet.
Des idées qui pourraient causer cela?
Merci
Une mise à jour: Si je fais ça marche:
string path = Assembly.GetExecutingAssembly().Location;
string directory = Path.GetDirectoryName(path);
NHibernateSession.Init(
new SimpleSessionStorage(),
new string[] { directory + "\\Persistence.dll", directory + "\\Model.dll" });
Update 2. Mon projet utilise le Sharp Architecture library. NHibernateSession est une classe qui appartient à cette bibliothèque.
Qu'est-ce que 'NHibernateSession'? Cela ne me semble pas être une partie native de NHibernate. S'il s'agit d'une classe personnalisée, il est difficile de vous aider sans avoir son code. Peut-être que c'est une classe générée par llblgenpro: il pourrait être préférable de leur demander leur soutien dans un tel cas. –
Et peut-être que vous auriez plus de facilité à laisser de côté llblgenpro et travailler directement avec vos mappings et votre atelier de session. Cela vous permettrait de les ajuster aux besoins de votre entreprise. (Vous pouvez en lire plus sur ma vue [ici] (/ a/35589532/1178314).) Et vous auriez plus d'options pour gérer l'initialisation de votre fabrique de session, comme celle de ma réponse [ici] (/ a/35711701/1178314). –
@ Frédéric: J'ai mis à jour mon message. Cette NHibernateSession appartient à la bibliothèque s # arp-architecture.Désolé, j'ai raté ça. – costa