Home
Options

Type resolution issues in custom driver

edited August 2012
I'm creating an open source LINQPad driver for NHibernate. You can find it at https://github.com/diegose/NHPad

The problem is, I can only get my ISessionFactory to build if the "client" assembly (the one containing the session factory building code) is located in the driver folder. Otherwise, NH is unable to locate the entity class... which is in the same (already loaded) assembly.

Any ideas?

Comments

  • Options
    Just to be clear: I know I'm doing something wrong with assembly loading there. I'm just not sure how to fix it (after all, it's my first driver and I wrote most of it in just a few hours...)
  • Options
    Can you provide more detail? How is NH unable to locate the entity class? What error message are you getting? And can you provide the stack trace and exception details where it throws? (You can attach to the LINQPad.exe process in Visual Studio and tell it to break on exceptions to find out where.)
  • Options
    Sure, here is the full exception:

    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> NHibernate.MappingException: Could not compile the mapping document: Mappings ---> NHibernate.MappingException: persistent class NHPad.Testbed.Blog, NHPad.Testbed not found ---> System.IO.FileNotFoundException: Could not load file or assembly 'NHPad.Testbed' or one of its dependencies. The system cannot find the file specified. at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at NHibernate.Util.ReflectHelper.TypeFromAssembly(AssemblyQualifiedTypeName name, Boolean throwOnError) at NHibernate.Util.ReflectHelper.ClassForName(String name) at NHibernate.Cfg.XmlHbmBinding.Binder.ClassForFullNameChecked(String fullName, String errorMessage) --- End of inner exception stack trace --- at NHibernate.Cfg.XmlHbmBinding.Binder.ClassForFullNameChecked(String fullName, String errorMessage) at NHibernate.Cfg.XmlHbmBinding.Binder.ClassForNameChecked(String name, Mappings mappings, String errorMessage) at NHibernate.Cfg.XmlHbmBinding.ClassBinder.BindClass(IEntityMapping classMapping, PersistentClass model, IDictionary`2 inheritedMetas) at NHibernate.Cfg.XmlHbmBinding.RootClassBinder.Bind(HbmClass classSchema, IDictionary`2 inheritedMetas) at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.AddRootClasses(HbmClass rootClass, IDictionary`2 inheritedMetas) at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.AddEntitiesMappings(HbmMapping mappingSchema, IDictionary`2 inheritedMetas) at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.Bind(HbmMapping mappingSchema) at NHibernate.Cfg.Configuration.AddDeserializedMapping(HbmMapping mappingDocument, String documentFileName) --- End of inner exception stack trace --- at NHibernate.Cfg.Configuration.LogAndThrow(Exception exception) at NHibernate.Cfg.Configuration.AddDeserializedMapping(HbmMapping mappingDocument, String documentFileName) at NHPad.Testbed.Configurator.GetSessionFactory() in C:\Users\mordejai\Documents\Visual Studio 2010\Projects\NHPad\NHPad.Testbed\Configurator.cs:line 17 --- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at NHPad.NHibernateStaticDataContextDriver.GetSessionFactory(IConnectionInfo cxInfo) in C:\Users\mordejai\Documents\Visual Studio 2010\Projects\NHPad\NHPad\NHibernateStaticDataContextDriver.cs:line 82

    To reproduce: build and add the driver, point it to NHPad.Testbed.dll
  • Options
    Does it make any difference if you disable shadow loading of assemblies? (Edit | Preferences | Advanced)
Sign In or Register to comment.