This is my first question on this page, so first of all, sorry for the newbieβs mistakes and my poor English.
I would not ask on such a page if I didnβt have enough ideas on how to solve my problem, so I hope that I will make money with your help, as this is my last chance.
I created a C # program using NHibernate to connect it to my Oracle database (which works fine), and now I was told to create a similar program, but now in a Windows service, not in .exe.
The problem is that I have all the settings necessary for NHibernate to work, as in the .exe program, and if I debug the program, everything works fine, but as soon as I install the service and start it, it will stop working.
I do not do nohing in the program, I just check the NHibernate connection.
An 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)
Part of the exception in Spanish says that it cannot find part of the access path.
This exception occurs when 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 I ask something, so I'm sorry for any mistake. Any help would be greatly appreciated.
Regards, Pole