I've played around with this and found that if I pass in the full path
on the config file, as in
sessionFactory = new Configuration().Configure(@"C:\...
\hibernate.cfg.xml").BuildSessionFactory();

then I don't get the exception from my OP.  But I instead get this
one:

{System.IO.FileNotFoundException: Could not load file or assembly
'NHibernate.ByteCode.Castle' or one of its dependencies. The system
cannot find the file specified.
File name: 'NHibernate.ByteCode.Castle'
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String
codeBase, Evidence assemblySecurity, Assembly locationHint,
StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean
forIntrospection)
   at System.Reflection.Assembly.nLoad(AssemblyName fileName, String
codeBase, Evidence assemblySecurity, Assembly locationHint,
StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean
forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName
assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark,
Boolean forIntrospection)
   at System.Reflection.Assembly.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) in c:\CSharp\NH
\nhibernate\src\NHibernate\Util\ReflectHelper.cs:line 280
   at NHibernate.Util.ReflectHelper.ClassForName(String name) in c:
\CSharp\NH\nhibernate\src\NHibernate\Util\ReflectHelper.cs:line 170
   at
NHibernate.Bytecode.Lightweight.BytecodeProviderImpl.SetProxyFactoryFactory
(String typeName) in c:\CSharp\NH\nhibernate\src\NHibernate\Bytecode
\Lightweight\BytecodeProviderImpl.cs:line 61

I tackle that by adding references to all the NH assemblies.  But then
I get this exception:

{NHibernate.HibernateException: The IDbCommand and IDbConnection
implementation in the assembly System.Data.SqlServerCe could not be
found. Ensure that the assembly System.Data.SqlServerCe is located in
the application directory or in the Global Assembly Cache. If the
assembly is in the GAC, use <qualifyAssembly/> element in the
application configuration file to specify the full name of the
assembly.
   at NHibernate.Driver.ReflectionBasedDriver..ctor(String
driverAssemblyName, String connectionTypeName, String commandTypeName)
in c:\CSharp\NH\nhibernate\src\NHibernate\Driver
\ReflectionBasedDriver.cs:line 27
   at NHibernate.Driver.SqlServerCeDriver..ctor() in c:\CSharp\NH
\nhibernate\src\NHibernate\Driver\SqlServerCeDriver.cs:line 18}

Etc. Etc.  So my question is: can I possibly force NH to look for all
needed resources -- configuration, assembly references, etc. --
relative to the currently executing assembly, instead of the entry
assembly.


On Jul 29, 12:19 pm, HappyNomad <[email protected]> wrote:
> I have an application that uses NH in its data-access layer.  My app
> is properly configured for the normal case of being directly
> launched.  However, I recently created another assembly (an IE add-on)
> that references the main assembly, and serves as the execution’s entry
> point in a separate process.  This satellite assembly references the
> main assembly, and depends on it for persisting changes to the
> database.  The satellite assembly, however, makes no reference of its
> own to NH.  Nor does it contain any NH configuration data.  Due in
> part to these circumstances perhaps, a problem occurs when the
> satellite assembly attempts to persist changes via the main assembly.
> That is, the following exception gets thrown:
>
> {System.IO.FileNotFoundException: Could not find file 'C:\Program Files
> \Internet Explorer\hibernate.cfg.xml'.
> File name: 'C:\Program Files\Internet Explorer\hibernate.cfg.xml'
>    at System.IO.__Error.WinIOError(Int32 errorCode, String
> maybeFullPath)
>    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
> access, Int32 rights, Boolean useRights, FileShare share, Int32
> bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
> msgPath, Boolean bFromProxy)
>    at System.IO.FileStream..ctor(String path, FileMode mode,
> FileAccess access, FileShare share, Int32 bufferSize)
>    at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
> credentials)
>    at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String
> role, Type ofObjectToReturn)
>    at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)
>    at System.Threading.CompressedStack.runTryCode(Object userData)
>    at
> System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup
> (TryCode code, CleanupCode backoutCode, Object userData)
>    at System.Threading.CompressedStack.Run(CompressedStack
> compressedStack, ContextCallback callback, Object state)
>    at System.Xml.XmlTextReaderImpl.OpenUrl()
>    at System.Xml.XmlTextReaderImpl.Read()
>    at System.Xml.XmlTextReader.Read()
>    at System.Xml.XmlCharCheckingReader.Read()
>    at System.Xml.XsdValidatingReader.Read()
>    at System.Xml.XPath.XPathDocument.LoadFromReader(XmlReader reader,
> XmlSpace space)
>    at System.Xml.XPath.XPathDocument..ctor(XmlReader reader, XmlSpace
> space)
>    at System.Xml.XPath.XPathDocument..ctor(XmlReader reader)
>    at NHibernate.Cfg.ConfigurationSchema.HibernateConfiguration..ctor
> (XmlReader hbConfigurationReader, Boolean fromAppSetting) in c:\CSharp
> \NH\nhibernate\src\NHibernate\Cfg\ConfigurationSchema
> \HibernateConfiguration.cs:line 46}
>
> So, my question is: can I possibly force NH to look for its
> configuration information in the current assembly (from which NH was
> directly called), rather than the execution’s entry assembly?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to