-->
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: error cs0234: the type or namespace "Cfg" does not
PostPosted: Sat May 21, 2005 3:33 am 
the class or namespace "NHibernate" (are you missing an assembly reference?)

i am trying to run the code below....



Code:
using Myhib = NHibernate;
using System;
//using User;
using Myhibc = NHibernate.Cfg;

public class Hibexample {

public Hibexample() {
Myhibc.Configuration cfg = new Myhibc.Configuration();
cfg.AddAssembly("NHibernate.Examples");
ISessionFactory factory = cfg.BuildSessionFactory();
}

public static void Main(String []args) {

Hibexample hibex = new Hibexample();
hibex.loadObject();

}


public void loadObject() {
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();

User newUser = new User();
newUser.Id = "joe_cool";
newUser.UserName = "Joseph Cool";
newUser.Password = "abc123";
newUser.EmailAddress = "joe@cool.com";
newUser.LastLogon = DateTime.Now;
         
// Tell NHibernate that this object should be saved
session.Save(newUser);

// commit all of the changes to the DB and close the ISession
transaction.Commit();
session.Close();
}

}


Top
  
 
 Post subject:
PostPosted: Sat May 21, 2005 4:36 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Did you reference the NHibernate.dll assembly?


Top
 Profile  
 
 Post subject: c:\winnt\microsoft.net\1.1.**\
PostPosted: Sat May 21, 2005 10:50 am 
i put it in c:\winnt\microsoft.net\1.1.**\

is that what u mean by *referencing* ?

cheers
sanjeev


Top
  
 
 Post subject:
PostPosted: Sat May 21, 2005 12:54 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
See this: http://blogs.msdn.com/csharpfaq/archive/2004/04/29/123028.aspx


Top
 Profile  
 
 Post subject: thankssssssssss
PostPosted: Sat May 21, 2005 9:56 pm 
well i managed to get rid of some of the errors by using the /r: option to compile.....

but i am still stuck because i don't know what assembly the
ISession, ISessionFactory and ITransaction classes belong to....

:-(


Top
  
 
 Post subject: fewer errors now only one
PostPosted: Sat May 21, 2005 11:18 pm 
ok...got rid of most of the errors....

now my problem is that i have a class called User.cs which is basically
the class which maps to a database table called user...

all the files are in a single directory and Hibexample.cs has references
to User.cs because it tries to insert a user record...

when i compile user.cs it says..there's no entry point defined...
when i compile hibexample.cs it gives me error cs0246..type or namespace user does not exist..are u missing a using directive or an assembly reference...

damn...this is aggravating...ought to be something simple i'm missing..but what ???%^%&^


Top
  
 
 Post subject: ugh...ugly error cannot get rid off...
PostPosted: Sun May 22, 2005 4:32 am 
hey

the namespace thing is clear now...good news....but the bad news is I got a newer error unrelated to the ones before...it is...

log4net error domconfigorator configurefromxml called with null element parameter.....woah...:-(


Top
  
 
 Post subject:
PostPosted: Sun May 22, 2005 5:04 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
That log4net error is harmless. Either ignore it, or if you want to make it go away, configure logging in your app.config. Examples should be in the log4net documentation, NHibernate sources, and I believe I saw an example on NHibernate Wiki.


Top
 Profile  
 
 Post subject: how do i make it go away ?
PostPosted: Sun May 22, 2005 6:11 am 
Hi
thanks but how do i make it go away ?
here is my config file ..

:-(


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"
    />
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
  </configSections>
   
  <nhibernate>
    <add
      key="hibernate.connection.provider"         
      value="NHibernate.Connection.DriverConnectionProvider"
    />
    <add
      key="hibernate.dialect"                     
      value="NHibernate.Dialect.MySQLDialect"
    />
    <add
      key="hibernate.connection.driver_class"         
      value="NHibernate.Driver.MySQLDriver"
    />
    <add
      key="hibernate.connection.connection_string"
      value="Server=localhost;initial catalog=hibdb;Integrated Security=SSPI"
    />
  </nhibernate>
  <!-- This section contains the log4net configuration settings -->
   <log4net debug="false">

      <!-- Define some output appenders -->   

      <appender name="rollingFile" type="log4net.Appender.RollingFileAppender,log4net" >
         
         <param name="File" value="log.txt" />
         <param name="AppendToFile" value="true" />
         <param name="RollingStyle" value="Date" />
         <param name="DatePattern" value="yyyy.MM.dd" />
         <param name="StaticLogFileName" value="true" />

         <layout type="log4net.Layout.PatternLayout,log4net">
            <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m%n" />
         </layout>
      </appender>

      <!-- Setup the root category, add the appenders and set the default priority -->
      
      <root>
         <priority value="ALL" />
         <appender-ref ref="rollingFile" />
      </root>
      
      
      
   </log4net>
</configuration>


Top
  
 
 Post subject: still not working....:-(
PostPosted: Sun May 22, 2005 6:13 am 
i tried with both debug set to true as well as false..

it doesn't work after the error is thrown....

cheers
sanjeev


Top
  
 
 Post subject: lognet configurator called with null element parameter
PostPosted: Mon May 23, 2005 11:04 am 
to all forum gurus - all you wise and all knowing and all powerful people...and still no one can help me ????????


Top
  
 
 Post subject: lognet configurator called with null element parameter error
PostPosted: Mon May 23, 2005 1:21 pm 
Posted: Mon May 23, 2005 5:05 pm Post subject: lognet configurator called with null element parameter error

--------------------------------------------------------------------------------

hi..

i am soooo dissapointed no one has tried to help me...

i am getting a lognet configurator called with null element parameter error.....

the program halts execution when this happens.....

so what am i doing wrong ? guys ? Hey pleasehelpmeman....

thx


Top
  
 
 Post subject:
PostPosted: Tue May 24, 2005 3:30 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Well, we are not log4net gurus, but NHibernate gurus :) your config looks right, the problem is somewhere else. Probably the program doesn't find your config file. If your application is named MyApp.exe, then the App.config should be copied to MyApp.exe.config and placed in the same directory as MyApp.exe. Visual Studio does this automatically, if you are using something else you have to do it manually.

By the way, that "null element parameter" error shouldn't halt your program - so there must be something else that halts it.


Top
 Profile  
 
 Post subject: ok thanks
PostPosted: Wed May 25, 2005 12:17 am 
well thanks for all your help.....

it is finally up and running pretty ok....

running a first example of nhibernate took me three days...

i am a newbie to dotnet too....just started a couple of weeks back...
well anyway.....

cheers.....nhibernate rocks !!!!


Top
  
 
 Post subject: Hi
PostPosted: Wed May 25, 2005 5:16 am 
Hello,
Can u tell me how u did to make it work ?? i 'm in the same case!!

Where did u place your cfg file and the connector ....

Thanks


Top
  
 
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.