Results 1 to 4 of 4

Thread: Nhibernate - sessionfactory

  1. #1
    Join Date
    Feb 2008
    Posts
    2

    Default Nhibernate - sessionfactory

    Hi Friends,

    Can anyone help me with session factory settings .Im getting mapping error.

    Regards
    M.Ramanathan
    arooun@rediffmail.com

  2. #2
    Join Date
    Oct 2006
    Location
    Bergen, Norway
    Posts
    365

    Default

    Hi!

    There is some really good documentation here.

    Maybe you already have read that chapter, in any case, feel free to post your stacktrace.

    Cheers,
    Steinar.

  3. #3
    Join Date
    Feb 2008
    Posts
    2

    Default stack trace

    sir,

    Below is the stack trace.
    ISession session = NHibernateHelper.GetCurrentSession();

    It shows error in the above line when the application breaks

    Stack Trace
    [FileNotFoundException: Could not load file or assembly 'nhiberchk' or one of its dependencies. The system cannot find the file specified.]
    System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
    System.Reflection.Assembly.InternalLoad(AssemblyNa me assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +211
    System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +141
    System.Reflection.Assembly.Load(String assemblyString) +25
    NHibernate.Cfg.Configuration.AddAssembly(String assemblyName) +93

    [MappingException: Could not add assembly named: nhiberchk]
    NHibernate.Cfg.Configuration.AddAssembly(String assemblyName) +201
    NHibernate.Cfg.Configuration.DoConfigure(XmlDocume nt doc) +1079
    NHibernate.Cfg.Configuration.Configure(XmlTextRead er reader) +449
    NHibernate.Cfg.Configuration.Configure(String resource) +94
    NHibernate.Cfg.Configuration.Configure() +81
    NHibernateHelper..cctor() in c:\Inetpub\wwwroot\nhiberchk\App_Code\NHMappings\N HibernateHelper.cs:12

    [TypeInitializationException: The type initializer for 'NHibernateHelper' threw an exception.]
    NHibernateHelper.GetCurrentSession() in c:\Inetpub\wwwroot\nhiberchk\App_Code\NHMappings\N HibernateHelper.cs:24
    Class1.save(String a, String b, String c, String d) in c:\Inetpub\wwwroot\nhiberchk\App_Code\NHMappings\C lass1.cs:26
    cat.Button1_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\nhiberchk\cat.aspx.cs:30
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96
    System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +116
    System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +31
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +32
    System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +72
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3838

  4. #4
    Join Date
    Oct 2006
    Location
    Bergen, Norway
    Posts
    365

    Default

    Hi!

    Do you mind posting the initialization of your NHibernateHelper. I recommend that you set up your Configuration object first. If you do, then you would isolate configuration issues from usage issues. Basically, it seems to me that the configuration has not been done before you suddenly try to invoke a save method on Class1. It would also help posting the save method of Class1.

    Anyway, the real issue is that the Configuration instance cannot load the assembly named 'nhiberchk'. The assembly cannot be found.

    Another smart thing to do is to dump the sql create schema script that NHibernate generates based on you mapping documents. This way you can analyze what sql your mappings end up as. Put this in a log.debug block if you want to avoid dumping this extra information all the time. In your case, you should never get a sql-dump because the mapping documents cannot be extracted as the assembly is not located.

    Code:
    ...
                if(log.IsDebugEnabled) 
                {
                    bool script = true; // dumps the script for logging purposes.
                    bool export = false; // if true, exports to db, means that it drops and recreates the db.
                    string file = nHibernate.Configuration.Constants.EXPORT_SCHEMA_NAME;
                    SchemaExport se = new SchemaExport(config);
                    se.SetOutputFile(file);
                    se.Create(script, export);
                }
    ...
    HTH,
    Steinar.
    Last edited by steinard; 03-11-2008 at 06:30 PM. Reason: Adding simple code example...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •