this is my first question on this page, so first of all sorry for any newbie mistakes and my bad english.
I wouldn’t be asking on a page like this if I didn’t ran out of ideas on how to solve my problem, so I hope I get it to work with your help since it’s my last chance.
I created a program in C# using NHibernate to connect it to my Oracle database (wich is working perfectly), and now I’ve been told to create a similar program, but now in a Windows Service instead of a .exe.
The problem is that I have all the settings done to make NHibernate work like in the .exe program, and if i debug the program it all works fine, but as soon as I install the service and run it, stops working.
I’m not doing anyhing in the program, just testing the NHibernate connection.
The exception:
Could not compile the mapping document: Mapping\CSB_Mensaje.hbm.xml
System.IO.DirectoryNotFoundException: No se puede encontrar una parte de la ruta de acceso 'C:\Windows\system32\Mapping\CSB_Mensaje.hbm.xml'.
en System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
en 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, Boolean useLongPath)
en System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
en System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
en System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
en System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)
en System.Threading.CompressedStack.runTryCode(Object userData)
en System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
en System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state)
en System.Xml.XmlTextReaderImpl.OpenUrl()
en System.Xml.XmlTextReaderImpl.Read()
en System.Xml.XmlTextReader.Read()
en System.Xml.XmlCharCheckingReader.Read()
en System.Xml.XsdValidatingReader.Read()
en System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
en System.Xml.XmlDocument.Load(XmlReader reader)
en NHibernate.Cfg.Configuration.LoadMappingDocument(XmlReader hbmReader, String name)
The part of the exception on spanish, says it can’t find a part of the access path.
This exception is thrown while trying to execute this code:
private static void Init(String BBDD)
{
Configuration config = new Configuration();
config.Configure().SessionFactoryName(BBDD);
config.AddFile("Mapping\\CSB_Mensaje.hbm.xml");
config.AddFile("Mapping\\CSB_Periodicidad.hbm.xml");
config.AddFile("Mapping\\CSB_Plantilla.hbm.xml");
config.AddFile("Mapping\\CSB_Subscripciones.hbm.xml");
config.AddFile("Mapping\\CSB_Usuario.hbm.xml");
config.AddFile("Mapping\\CSB_Login.hbm.xml");
config.AddFile("Mapping\\CSB_Configuration.hbm.xml");
_SessionFactory = config.BuildSessionFactory();
}
And this is my hibernate.cfg.xml file:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name="Oracle">
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="dialect">
NHibernate.Dialect.Oracle10gDialect
</property>
<property name="connection.driver_class">
NHibernate.Driver.OracleClientDriver
</property>
<property name="connection.connection_string">
User Id=CSB;
Password=Hound2012;
Data Source=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.30)(PORT = 1521)))(CONNECT_DATA = (SID = HL)));
</property>
<property name="show_sql">
true
</property>
</session-factory>
</hibernate-configuration>
Again, this is my first time asking something here, so I’m sorry for any mistake made. Any help would be greatly apreciated.
Regards,
Khor
This line of the exception message indicates the problem:
I think the problem is that you are using relative paths here:
Try specifying the actual path to the mapping files.
Alternatively, mark your mapping files as embedded resources and let NHibernate find them in the assembly instead of telling the configuration about each one individually (see The NHibernate Wiki).