-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Unrecognized configuration section hibernate-configuration
PostPosted: Wed Feb 21, 2007 7:47 pm 
Regular
Regular

Joined: Sun Jan 21, 2007 4:33 pm
Posts: 65
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 1.0.4

Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
    <class name="SocksCDS.Wages, SocksCDS" table="tblWages">
        <id name="WagesID" column="WagesID" type="int" length="5">
            <generator class="identity" />
        </id>
        <property name="WagesAmount" />
        <property name="UnemploymentAmount" />
   <property name="SSIDisabilityAmount" />
        <property name="FoodStampsAmount" />
   <property name="SocialSecurityAmount" />
   <property name="ChildSupportAmount" />
   <property name="ClientID" />

   <set name="Wages" cascade="all" lazy="true">
            <KEY column="ClientID" />
            <MANY-TO-ONE name="Client" class="SocksCDS.Client, SocksCDS" column="ClientID" />
        </set>
    </class>
</hibernate-mapping>

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
    <class name="SocksCDS.Client, SocksCDS" table="tblSpouse">
        <id name="SpouseID" column="SpouseID" type="int" length="5">
            <generator class="identity" />
        </id>
        <property name="SpouseLastName" />
        <property name="SpouseFirstName" />
   <property name="SpouseSSN" />
   <property name="SpouseEmployer" />       
   <set name="Spouse" cascade="all" lazy="true">
            <KEY column="ClientID" />
            <MANY-TO-ONE name="Client" class="SocksCDS.Client, SocksCDS" column="ClientID" />
        </set>
    </class>
</hibernate-mapping>


Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
    <class name="SocksCDS.Employer, SocksCDS" table="tblEmployer">
        <id name="EmployerID" column="EmployerID" type="int" length="5">
            <generator class="identity" />
        </id>
        <property name="EmployerName" />
        <property name="ClientID" />
   <set name="Employer" cascade="all" lazy="true">
            <KEY column="ClientID" />
            <MANY-TO-ONE name="Client" class="SocksCDS.Client, SocksCDS" column="ClientID"/>
        </set>
    </class>
</hibernate-mapping>

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
    <class name="SocksCDS.Client, SocksCDS" table="tblClient">
        <id name="ClientID" column="ClientID" type="int" length="5">
            <generator class="identity" />
        </id>
        <property name="LastName" />
        <property name="FirstName" />
   <property name="ClientSSN" />
        <property name="Street" />
   <property name="City" />
   <property name="ZipCode" />
   <property name="State" />
   <property name="PhoneNumber" />
   <property name="Sex" />
   <property name="Race" />
   <property name="MaritalStatus" />
   <property name="AuthorizedPerson1" />
   <property name="AuthorizedPerson2" />

        <property name="ApplicationDate" />
      <set name="Child" cascade="all" lazy="true">
        <KEY column="ClientID" />
        <ONE-TO-MANY class="SocksCDS.Child, SocksCDS" />
      </set>
      <set name="Spouse" cascade="all" lazy="true">
        <KEY column="ClientID" />
        <ONE-TO-MANY class="SocksCDS.Spouse, SocksCDS" />
      </set>
      <set name="Wages" cascade="all" lazy="true">
        <KEY column="ClientID" />
        <ONE-TO-MANY class="SocksCDS.Wages, SocksCDS" />
      </set>
      <set name="Employer" cascade="all" lazy="true">
        <KEY column="ClientID" />
        <ONE-TO-MANY class="SocksCDS.Employer, SocksCDS" />
      </set>
      <set name="Assistance" cascade="all" lazy="true">
        <KEY column="ClientID" />
        <ONE-TO-MANY class="SocksCDS.Assistance, SocksCDS" />
      </set>
     </class>


</hibernate-mapping>

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
    <class name="SocksCDS.Child, SocksCDS" table="tblChildren">
        <id name="ChildID" column="ChildID" type="int" length="5">
            <generator class="identity" />
        </id>
   <property name="ChildSSN" column="ChildSSN" type="long" length="9"/>       
   <property name="LastName" column="LastName" type="String" length="40"/>
        <property name="FirstName" column="FirstName" type="String" length="20"/>
   <property name="BirthDate" column="BirthDate" type="DateTime"/>
   <property name="ClientID" column="ClientID" type="long" length="5"/>
     </class>
   <SET name="Child" cascade="all" lazy="true">
            <KEY column="ClientID" />
            <MANY-TO-ONE name="Client" class="SocksCDS.Client, SocksCDS" column="ClientID"/>
        </SET>
</hibernate-mapping>




Code between sessionFactory.openSession() and session.close():

Code:
Configuration cfg = new Configuration();
            cfg.AddAssembly("SocksCDS");           
            ISessionFactory factory = cfg.BuildSessionFactory();
            ISession session = factory.OpenSession();
            ITransaction transaction = session.BeginTransaction();
           
           
            Client newClient = new Client ();
            newClient.PhoneNumber = txtClientPhoneNumber.Text;
            newClient.Sex = txtClientSex.Text;
            newClient.State = txtClientState.Text;
            newClient.ZipCode = txtClientZipCode.Text;
            newClient.LastName = txtClientLastName.Text;
            newClient.FirstName = txtClientFirstName.Text;
            newClient.Street = txtClientStreet.Text;
            newClient.Ssn = txtClientSSN.Text;
            newClient.City = txtClientCity.Text;
            newClient.ClientMI = txtMI.Text;
            newClient.MaritalStatus = comboMaritalStatus.Text;
            newClient.ApplicationDate = txtApplicationDate.Text;

            session.Save(newClient);
            transaction.Commit();
            session.Close();


Full stack trace of any exception that occurs:
Code:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.TypeInitializationException: The type initializer for 'NHibernate.Cfg.Configuration' threw an exception. ---> System.TypeInitializationException: The type initializer for 'log4net.Core.LoggerManager' threw an exception. ---> System.TypeInitializationException: The type initializer for 'log4net.Util.LogLog' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section hibernate-configuration. (E:\Documents and Settings\George\My Documents\Visual Studio 2005\Projects\Socks CDS\bin\Debug\Socks CDS.exe.config line 9)
   at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
   at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
   at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
   at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
   --- End of inner exception stack trace ---
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
   at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
   at System.Diagnostics.DiagnosticsConfiguration.Initialize()
   at System.Diagnostics.DiagnosticsConfiguration.get_IndentSize()
   at System.Diagnostics.TraceInternal.InitializeSettings()
   at System.Diagnostics.TraceInternal.WriteLine(String message)
   at System.Diagnostics.Trace.WriteLine(String message)
   at log4net.Util.LogLog.Error(String message, Exception exception)
   at log4net.Util.LogLog..cctor()
   --- End of inner exception stack trace ---
   at log4net.Util.LogLog.Debug(String message)
   at log4net.Core.LoggerManager..cctor()
   --- End of inner exception stack trace ---
   at log4net.Core.LoggerManager.GetLogger(Assembly repositoryAssembly, String name)
   at log4net.LogManager.GetLogger(Type type)
   at NHibernate.Cfg.Configuration..cctor()
   --- End of inner exception stack trace ---
   at NHibernate.Cfg.Configuration..ctor()
   at SocksCDS.Form2.btnSaveClientInformation_Click(Object sender, EventArgs e) in E:\Documents and Settings\George\My Documents\Visual Studio 2005\Projects\Socks CDS\Form2.cs:line 98
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///E:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Socks CDS
    Assembly Version: 0.0.1.1
    Win32 Version: 0.0.1.1
    CodeBase: file:///E:/Documents%20and%20Settings/George/My%20Documents/Visual%20Studio%202005/Projects/Socks%20CDS/bin/Debug/Socks%20CDS.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
NHibernate
    Assembly Version: 1.0.4.0
    Win32 Version: 1.0.4.0
    CodeBase: file:///E:/Documents%20and%20Settings/George/My%20Documents/Visual%20Studio%202005/Projects/Socks%20CDS/bin/Debug/NHibernate.DLL
----------------------------------------
SocksCDS
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///E:/Documents%20and%20Settings/George/My%20Documents/Visual%20Studio%202005/Projects/Socks%20CDS/bin/Debug/SocksCDS.DLL
----------------------------------------
System.Data
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///E:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
log4net
    Assembly Version: 1.2.9.0
    Win32 Version: 1.2.9.0
    CodeBase: file:///E:/Documents%20and%20Settings/George/My%20Documents/Visual%20Studio%202005/Projects/Socks%20CDS/bin/Debug/log4net.DLL
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.


Name and version of the database you are using:
Access 2003



Here is the app.config file and the hibernate.cfg.xml file as well:

app.config
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </configSections>
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.0">
    <session-factory>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="dialect">NHibernate.JetDriver.JetDialect, NHibernate.JetDriver</property>
      <property name="connection.driver_class">NHibernate.JetDriver.JetDriver, NHibernate.JetDriver</property>
      <property name="connection.connection_string">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Socks\Database\SocksCDS.mdb</property>

      <!-- mapping files -->
      <mapping resource="Client.hbm.xml" assembly="SocksCDS.Client" />
      <mapping resource="Child.hbm.xml" assembly="SocksCDS.Child" />
      <mapping resource="Spouse.hbm.xml" assembly="SocksCDS.Spouse" />
      <mapping resource="Employer.hbm.xml" assembly="SocksCDS.Employer" />
      <mapping resource="Assistance.hbm.xml" assembly="SocksCDS.Assistance" />
      <mapping resource="Wages.hbm.xml" assembly="SocksCDS.Wages" />
    </session-factory>
  </hibernate-configuration>
  <system.windows.forms jitDebugging="true" />
</configuration>


hibernate.cfg.xml

Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section
      name="nhibernate"
      type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    />
  </configSections>
  <hibernate-configuration  xmlns="urn:nhibernate-configuration-2.0" >
    <session-factory>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="dialect">NHibernate.JetDriver.JetDialect, NHibernate.JetDriver</property>
      <property name="connection.driver_class">NHibernate.JetDriver.JetDriver, NHibernate.JetDriver</property>
      <property name="connection.connection_string">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Socks\Database\SocksCDS.mdb</property>

      <!-- mapping files -->
      <mapping resource="Client.hbm.xml" assembly="SocksCDS.Client" />
      <mapping resource="Child.hbm.xml" assembly="SocksCDS.Child" />
      <mapping resource="Spouse.hbm.xml" assembly="SocksCDS.Spouse" />
      <mapping resource="Employer.hbm.xml" assembly="SocksCDS.Employer" />
      <mapping resource="Assistance.hbm.xml" assembly="SocksCDS.Assistance" />
      <mapping resource="Wages.hbm.xml" assembly="SocksCDS.Wages" />
    </session-factory>
  </hibernate-configuration>
</configuration>


The classes that these map to are wrapped up in a .dll called SocksCDS.dll.

Any help is appreciated : I'm certain that I've screwed up somewhere, I'm just not sure where.

Here's what the database itself looks like, relationship wise.

Image

Again, any help is appreciated. Should you need me to post the classes, I can do that as well.[/img]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 21, 2007 10:09 pm 
Regular
Regular

Joined: Tue Aug 08, 2006 4:28 am
Posts: 96
Location: Hong Kong
Please replace
Code:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.0">

with
Code:
<hibernate>

in App.config and hibernate.cfg.xml

And don't forget the closing tag as well.


BTW, why do you need 2 identical configuration files?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 22, 2007 12:21 am 
Regular
Regular

Joined: Sun Jan 21, 2007 4:33 pm
Posts: 65
canton wrote:
Please replace
Code:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.0">

with
Code:
<hibernate>

in App.config and hibernate.cfg.xml

And don't forget the closing tag as well.


BTW, why do you need 2 identical configuration files?


Well, some help files I look at say to use a hibernate.cfg.xml, and others say to stick it in the app.config.

In the end, I just want it to work, but if you *know* which one works all of the time, I'll switch it to that one.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 22, 2007 12:30 am 
Regular
Regular

Joined: Tue Aug 08, 2006 4:28 am
Posts: 96
Location: Hong Kong
Any of the two will do. I personally choose app.config for laziness :)

app.config is a common way for all configurations. E.g. log4net.

hibernate.cfg.xml is an alternative to let you separate (N)Hibernate configurations into another file.


Top
 Profile  
 
 Post subject: Another Isssue
PostPosted: Thu Feb 22, 2007 10:55 pm 
Regular
Regular

Joined: Sun Jan 21, 2007 4:33 pm
Posts: 65
Well, I have this issue now.

I realize that some of you may wonder why I'm bringing this issue to you: Quite simply, I've read the documentation, read the quickstart guide, and have poured through every resource imaginable, (Short of buying Hibernate in Action -- though I'm quite anxious for the Nhibernate in Action to come out) to determine what I'm doing wrong here.

I've made the fixes, and now I get the following exception:
Code:
System.TypeInitializationException was unhandled
  Message="The type initializer for 'NHibernate.Cfg.Environment' threw an exception."
  Source="NHibernate"
  TypeName="NHibernate.Cfg.Environment"
  StackTrace:
       at NHibernate.Cfg.Environment.get_Properties()
       at NHibernate.Cfg.Configuration.Reset()
       at NHibernate.Cfg.Configuration..ctor()
       at SocksCDS.Form2.btnSaveClientInformation_Click(Object sender, EventArgs e) in C:\Code Projects\Visual Studio 2005\Projects\Socks CDS\Form2.cs:line 99
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at SocksCDS.Program.Main() in C:\Code Projects\Visual Studio 2005\Projects\Socks CDS\Program.cs:line 21
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()


Note, I get the same exact exception whether the app.config 's <hibernate> is so named, or is named <nhibernate>

For reference, here is the app.config:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </configSections>
  <hibernate>
    <session-factory>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="dialect">NHibernate.JetDriver.JetDialect, NHibernate.JetDriver</property>
      <property name="connection.driver_class">NHibernate.JetDriver.JetDriver, NHibernate.JetDriver</property>
      <property name="connection.connection_string">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Socks\Database\SocksCDS.mdb</property>

      <!-- mapping files -->
      <mapping resource="Client.hbm.xml" assembly="SocksCDS.Client" />
      <mapping resource="Child.hbm.xml" assembly="SocksCDS.Child" />
      <mapping resource="Spouse.hbm.xml" assembly="SocksCDS.Spouse" />
      <mapping resource="Employer.hbm.xml" assembly="SocksCDS.Employer" />
      <mapping resource="Assistance.hbm.xml" assembly="SocksCDS.Assistance" />
      <mapping resource="Wages.hbm.xml" assembly="SocksCDS.Wages" />
    </session-factory>
  </hibernate>
</configuration>


I'm hoping someone, somewhere has seen this issue, or knows where I went wrong.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 23, 2007 12:21 am 
Regular
Regular

Joined: Tue Aug 08, 2006 4:28 am
Posts: 96
Location: Hong Kong
Let's choose the hibernate.cfg.xml approach and remove nhibernate configurations in app.config. Moreover, we don't need config section in hibernate.cfg.xml

In hibernate.cfg.xml
Code:
<?xml version='1.0' encoding='utf-8'?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.0">

    <session-factory>
   
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="dialect">NHibernate.JetDriver.JetDialect, NHibernate.JetDriver</property>
      <property name="connection.driver_class">NHibernate.JetDriver.JetDriver, NHibernate.JetDriver</property>
      <property name="connection.connection_string">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Socks\Database\SocksCDS.mdb</property>

      <!-- mapping files -->
      <mapping resource="Client.hbm.xml" assembly="SocksCDS.Client" />
      <mapping resource="Child.hbm.xml" assembly="SocksCDS.Child" />
      <mapping resource="Spouse.hbm.xml" assembly="SocksCDS.Spouse" />
      <mapping resource="Employer.hbm.xml" assembly="SocksCDS.Employer" />
      <mapping resource="Assistance.hbm.xml" assembly="SocksCDS.Assistance" />
      <mapping resource="Wages.hbm.xml" assembly="SocksCDS.Wages" />
    
    </session-factory>
   
</hibernate-configuration>


In App.config

Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.windows.forms jitDebugging="true" />
</configuration>


Hope this helps


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 23, 2007 2:22 am 
Regular
Regular

Joined: Sun Jan 21, 2007 4:33 pm
Posts: 65
I'll try that.

Do I need an extra line of code in my program for it to look for the hibernate.cfg.xml file?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 23, 2007 2:53 am 
Regular
Regular

Joined: Tue Aug 08, 2006 4:28 am
Posts: 96
Location: Hong Kong
You will need

Code:
Configuration cfg = new Configuration();
cfg.Configure();


One thing that you might miss is to set "Copy to Output Directory" property of hibernate.cfg.xml to "Copy if newer" or "Copy Always".


Top
 Profile  
 
 Post subject: FileNotFound...
PostPosted: Fri Feb 23, 2007 1:08 pm 
Regular
Regular

Joined: Sun Jan 21, 2007 4:33 pm
Posts: 65
Now I get a 'filenotfound' exception when it trys to load SocksCDS.Client. Here is the Exception information.

Code:
System.IO.FileNotFoundException was unhandled
  Message="Could not load file or assembly 'SocksCDS.Client' or one of its dependencies. The system cannot find the file specified."
  Source="mscorlib"
  FileName="SocksCDS.Client"
  FusionLog="=== Pre-bind state information ===\r\nLOG: User = DOR\\George\r\nLOG: DisplayName = SocksCDS.Client\n (Partial)\r\nLOG: Appbase = file:///C:/Code Projects/Visual Studio 2005/Projects/Socks CDS/bin/Debug/\r\nLOG: Initial PrivatePath = NULL\r\nCalling assembly : NHibernate, Version=1.0.4.0, Culture=neutral, PublicKeyToken=154fdcb44c4484fc.\r\n===\r\nLOG: This bind starts in default load context.\r\nLOG: Using application configuration file: C:\\Code Projects\\Visual Studio 2005\\Projects\\Socks CDS\\bin\\Debug\\Socks CDS.vshost.exe.config\r\nLOG: Using machine configuration file from E:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\config\\machine.config.\r\nLOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).\r\nLOG: Attempting download of new URL file:///C:/Code Projects/Visual Studio 2005/Projects/Socks CDS/bin/Debug/SocksCDS.Client.DLL.\r\nLOG: Attempting download of new URL file:///C:/Code Projects/Visual Studio 2005/Projects/Socks CDS/bin/Debug/SocksCDS.Client/SocksCDS.Client.DLL.\r\nLOG: Attempting download of new URL file:///C:/Code Projects/Visual Studio 2005/Projects/Socks CDS/bin/Debug/SocksCDS.Client.EXE.\r\nLOG: Attempting download of new URL file:///C:/Code Projects/Visual Studio 2005/Projects/Socks CDS/bin/Debug/SocksCDS.Client/SocksCDS.Client.EXE.\r\n"
  StackTrace:
       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.Cfg.Configuration.DoConfigure(XmlDocument doc)
       at NHibernate.Cfg.Configuration.Configure(XmlTextReader reader)
       at NHibernate.Cfg.Configuration.Configure(String resource)
       at NHibernate.Cfg.Configuration.Configure()
       at SocksCDS.Form2.btnSaveClientInformation_Click(Object sender, EventArgs e) in C:\Code Projects\Visual Studio 2005\Projects\Socks CDS\Form2.cs:line 100
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at SocksCDS.Program.Main() in C:\Code Projects\Visual Studio 2005\Projects\Socks CDS\Program.cs:line 21
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()


I refuse to believe that anyone has this much trouble with NHibernate, so I'm convinced I did something wrong.

I'm just not sure what.

I wrapped the classes up into a .dll file called SocksCDS.dll, I included it as a reference at first (and used the appropriate namespace:
Code:
using SocksCDS;

But after that didn't work ( I got the same error as above), so I instead included it in the project itself, as an 'embedded resource'. That also produces the error above.

Here's a picture of the files in the 'Solution Explorer'.

Again, any help is appreciated, I know your time is precious.
Image[/img]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 23, 2007 10:36 pm 
Regular
Regular

Joined: Tue Aug 08, 2006 4:28 am
Posts: 96
Location: Hong Kong
I guess it helps if you replace
Code:
<mapping resource="Client.hbm.xml" assembly="SocksCDS.Client" />

with
Code:
<mapping resource="Client.hbm.xml" assembly="SocksCDS" />

It expects the assembly name but I guess you have put the namespace.

BTW, where is Client.cs ?


Top
 Profile  
 
 Post subject: Ererrr...
PostPosted: Fri Feb 23, 2007 11:00 pm 
Regular
Regular

Joined: Sun Jan 21, 2007 4:33 pm
Posts: 65
I did that later after the first one didn't work.

I'll take it off and see if that works.

All of the classes are inside of the SocksCDS.dll file. Nhibernate no likely dll files?


Top
 Profile  
 
 Post subject: Mapping Exception
PostPosted: Sat Feb 24, 2007 10:28 pm 
Regular
Regular

Joined: Sun Jan 21, 2007 4:33 pm
Posts: 65
An unhandled exception of type 'NHibernate.MappingException' occurred in NHibernate.dll

Additional information: The element 'set' in namespace 'urn:nhibernate-mapping-2.0' has invalid child element 'KEY' in namespace 'urn:nhibernate-mapping-2.0'. List of possible elements expected: 'urn:nhibernate-mapping-2.0:meta urn:nhibernate-mapping-2.0:jcs-cache urn:nhibernate-mapping-2.0:cache urn:nhibernate-mapping-2.0:key'.

Doh. Any ideas of where this comes from? The cfg file is below:

Code:
<?xml version="1.0" encoding="utf-8" ?>
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.0">

    <session-factory>

      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="dialect">NHibernate.JetDriver.JetDialect, NHibernate.JetDriver</property>
      <property name="connection.driver_class">NHibernate.JetDriver.JetDriver, NHibernate.JetDriver</property>
      <property name="connection.connection_string">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Socks\Database\SocksCDS.mdb</property>

      <!-- mapping files -->
      <mapping resource="SocksCDS.Client.hbm.xml" assembly="SocksCDS" />
      <mapping resource="Child.hbm.xml" assembly="SocksCDS" />
      <mapping resource="Spouse.hbm.xml" assembly="SocksCDS" />
      <mapping resource="Employer.hbm.xml" assembly="SocksCDS" />
      <mapping resource="Assistance.hbm.xml" assembly="SocksCDS" />
      <mapping resource="Wages.hbm.xml" assembly="SocksCDS" />

    </session-factory>

  </hibernate-configuration>


The other files (the *.hbm.xml files) are given in my previous posts in this thread.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 25, 2007 10:11 pm 
Regular
Regular

Joined: Tue Aug 08, 2006 4:28 am
Posts: 96
Location: Hong Kong
SET can't be used for many-to-one relationship. Please check documentation.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 26, 2007 2:49 pm 
Regular
Regular

Joined: Sun Jan 21, 2007 4:33 pm
Posts: 65
canton wrote:
SET can't be used for many-to-one relationship. Please check documentation.
Yup, you are right. I'm fixing my mapping documents now. I hope that fixes the issue.


Top
 Profile  
 
 Post subject: Now the dialect isn't set?
PostPosted: Mon Feb 26, 2007 5:37 pm 
Regular
Regular

Joined: Sun Jan 21, 2007 4:33 pm
Posts: 65
Alright, I think I'm beginning to think that I'm going nuts.

FWIW, I've cleared the previous bugs with fixes mentioned in this forum. Thank you.

Now it's giving me the message:
Code:
"The dialect was not set. Set the property hibernate.dialect."


Which I've seen elsewhere, but the fix mentioned 'renaming app.config.xml to app.config' doesn't work for two reasons (first my stuff is located in hibernate.cfg.xml, secondly because my app.config is named like it should be.

For the curious, here is what my hibernate.cfg.xml file contains:
Code:
<?xml version="1.0" encoding="utf-8" ?>
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.0">

    <session-factory>

      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="dialect">NHibernate.JetDriver.JetDialect, NHibernate.JetDriver</property>
      <property name="connection.driver_class">NHibernate.JetDriver.JetDriver, NHibernate.JetDriver</property>
      <property name="connection.connection_string">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Socks\Database\SocksCDS.mdb</property>

      <!-- mapping files -->
      <mapping resource="SocksCDS.Client.hbm.xml" assembly="Socks CDS" />
      <mapping resource="Child.hbm.xml" assembly="Socks CDS" />
      <mapping resource="Spouse.hbm.xml" assembly="Socks CDS" />
      <mapping resource="Employer.hbm.xml" assembly="Socks CDS" />
      <mapping resource="Assistance.hbm.xml" assembly="Socks CDS" />
      <mapping resource="Wages.hbm.xml" assembly="Socks CDS" />

    </session-factory>

  </hibernate-configuration>


Any help is appreciated, as well as pointers as to a list of other possible fixes. By all accounts, the property *looks* set.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.