Well, if FSessionFactory is null, it _clearly_ is a problem with
initializing or setting FSessionFactory, so that is what you need to fix.
Maybe there are multiple problems, but that is the one you must figure out
first.

On the other hand you started this conversation with a
NHibernate.Exceptions.GenericADOException and when I asked for the inner
exception you return with a NullReferenceException in _your_ code. While
not impossible it would be unusual for that to show up inside an exception
from NH. So I'm confused, suspect that you may have changed something else,
or that there are multiple separate issues.

Impossible to tell, you need to try to find a systematic approach. Remove
the problematic mapping, verify that it runs. Add in the problematic
mapping and then catch the full exception including inner exceptions
recursively. Hint: If you use ToString() instead of the Message property on
the top-level exception you will get all subexceptions including their
messages and stacktraces.

/Oskar



2017-08-13 12:11 GMT+01:00 Ganesh Gebhard <[email protected]>:

> It is definitely a mapping error, because when I remove the mapping
> everything works fine. The try-catch didn't work, because something else
> began to give the exact same error. so are there any other options?
>
> Op zondag 13 augustus 2017 11:56:55 UTC+2 schreef Gunnar Liljas:
>>
>> FSessionFactory is null, which probably is due to a mapping error. Add a
>> try catch around the part where FSessionFactory is instantiated.
>>
>> 2017-08-12 17:32 GMT+02:00 Ganesh Gebhard <[email protected]>:
>>
>>> Hi Oskar,
>>>
>>> Thanks for the advice, the message is now 'Object reference not set to
>>> an instance of an object.'
>>>
>>> However, I cannot figure out why this is the problem.
>>>
>>> Op zaterdag 12 augustus 2017 11:05:48 UTC+2 schreef Oskar Berggren:
>>>>
>>>> GenereicAdoException will have an InnerException property, and that in
>>>> turn may also have an InnerException and so on. These will often tell you
>>>> what the problem is.
>>>>
>>>> /Oskar
>>>>
>>>> 2017-08-11 1:44 GMT+01:00 Ganesh Gebhard <[email protected]>:
>>>>
>>>>> Sure. Everytime I want to add a new table, I get the following error:
>>>>>
>>>>> NHibernate.Exceptions.GenericADOException occurred
>>>>>
>>>>>   HResult=0x80131600
>>>>>
>>>>>   Message=could not execute query
>>>>>
>>>>> [ select dcsv0_.id as id3_, dcsv0_.fnaam as fnaam3_, dcsv0_.fvolgorde
>>>>> as fvolgorde3_, dcsv0_.ftype as ftype3_, dcsv0_.fglobal as fglobal3_,
>>>>> dcsv0_.fmachine as fmachine3_, dcsv0_.fparameter as fparameter3_ from DCSV
>>>>> dcsv0_ ]
>>>>>
>>>>> [SQL: select dcsv0_.id as id3_, dcsv0_.fnaam as fnaam3_,
>>>>> dcsv0_.fvolgorde as fvolgorde3_, dcsv0_.ftype as ftype3_, dcsv0_.fglobal 
>>>>> as
>>>>> fglobal3_, dcsv0_.fmachine as fmachine3_, dcsv0_.fparameter as 
>>>>> fparameter3_
>>>>> from DCSV dcsv0_]
>>>>>
>>>>>   Source=NHibernate
>>>>>
>>>>>   StackTrace:
>>>>>
>>>>>    at NHibernate.Loader.Loader.DoList(ISessionImplementor session,
>>>>> QueryParameters queryParameters, IResultTransformer 
>>>>> forcedResultTransformer)
>>>>>
>>>>>    at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor
>>>>> session, QueryParameters queryParameters)
>>>>>
>>>>>    at NHibernate.Loader.Loader.List(ISessionImplementor session,
>>>>> QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes)
>>>>>
>>>>>    at NHibernate.Loader.Hql.QueryLoader.List(ISessionImplementor
>>>>> session, QueryParameters queryParameters)
>>>>>
>>>>>    at 
>>>>> NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor
>>>>> session, QueryParameters queryParameters)
>>>>>
>>>>>    at NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters
>>>>> queryParameters, ISessionImplementor session, IList results)
>>>>>
>>>>>    at NHibernate.Impl.SessionImpl.List(IQueryExpression
>>>>> queryExpression, QueryParameters queryParameters, IList results)
>>>>>
>>>>>    at NHibernate.Impl.AbstractSessionImpl.List(IQueryExpression
>>>>> queryExpression, QueryParameters parameters)
>>>>>
>>>>>    at NHibernate.Impl.AbstractQueryImpl2.List()
>>>>>
>>>>>    at NHibernate.Linq.DefaultQueryProvider.ExecuteQuery(NhLinqExpression
>>>>> nhLinqExpression, IQuery query, NhLinqExpression nhQuery)
>>>>>
>>>>>    at NHibernate.Linq.DefaultQueryProvider.Execute(Expression
>>>>> expression)
>>>>>
>>>>>    at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression
>>>>> expression)
>>>>>
>>>>>    at Remotion.Linq.QueryableBase`1.GetEnumerator()
>>>>>
>>>>>    at NHDataCore.NHTable`1.<AsEnumerable>d__14.MoveNext() in
>>>>> E:\Documenten\Weighpack\New Database 3\OMS-Development-3718907727c4
>>>>> a695ff28360f4d3e9ea946495840\NHDataCore\NHDataCore\NHTable.cs:line 172
>>>>>
>>>>>    at OMS2.Model.CSVs.refresh() in E:\Documenten\Weighpack\New
>>>>> Database 
>>>>> 3\OMS-Development-3718907727c4a695ff28360f4d3e9ea946495840\OMS2\Model\CSVs.cs:line
>>>>> 39
>>>>>
>>>>>    at OMS2.Model.CSVs..ctor(DataModel AModel) in
>>>>> E:\Documenten\Weighpack\New Database 3\OMS-Development-3718907727c4
>>>>> a695ff28360f4d3e9ea946495840\OMS2\Model\CSVs.cs:line 32
>>>>>
>>>>>    at OMS2.Model.DataModel.LoadAllData() in
>>>>> E:\Documenten\Weighpack\New Database 3\OMS-Development-3718907727c4
>>>>> a695ff28360f4d3e9ea946495840\OMS2\Model\DataModel.cs:line 156
>>>>>
>>>>>    at OMS2.Model.DataModel..ctor() in E:\Documenten\Weighpack\New
>>>>> Database 
>>>>> 3\OMS-Development-3718907727c4a695ff28360f4d3e9ea946495840\OMS2\Model\DataModel.cs:line
>>>>> 128
>>>>>
>>>>>    at OMS2.MainWindow.InitializeOMS() in E:\Documenten\Weighpack\New
>>>>> Database 
>>>>> 3\OMS-Development-3718907727c4a695ff28360f4d3e9ea946495840\OMS2\MainWindow.xaml.cs:line
>>>>> 69
>>>>>
>>>>>    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate
>>>>> callback, Object args, Int32 numArgs)
>>>>>
>>>>>    at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object
>>>>> source, Delegate callback, Object args, Int32 numArgs, Delegate
>>>>> catchHandler)
>>>>>
>>>>>
>>>>> The code for adding the new table in the database is:
>>>>>
>>>>>
>>>>> using NHDataCore;
>>>>>
>>>>> using FluentNHibernate.Mapping;
>>>>>
>>>>>
>>>>> namespace OMS2.Model.Entities
>>>>>
>>>>> {
>>>>>
>>>>>     public class DCSV : NHRow
>>>>>
>>>>>     {
>>>>>
>>>>>         [Indexed]
>>>>>
>>>>>
>>>>>         public virtual string naam { get; set; }
>>>>>
>>>>>         public virtual int volgorde { get; set; }
>>>>>
>>>>>         public virtual string type { get; set; }
>>>>>
>>>>>         public virtual string global { get; set; }
>>>>>
>>>>>         public virtual string machine { get; set; }
>>>>>
>>>>>         public virtual string parameter { get; set; }
>>>>>
>>>>>     }
>>>>>
>>>>>
>>>>>     public class DCSVMap : ClassMap<DCSV>
>>>>>
>>>>>     {
>>>>>
>>>>>         public DCSVMap()
>>>>>
>>>>>         {
>>>>>
>>>>>             Table("DCSV");
>>>>>
>>>>>             Cache.NonStrictReadWrite();
>>>>>
>>>>>             Id(x => x.id).GeneratedBy.Native();
>>>>>
>>>>>             Map(x => x.naam, "fnaam");
>>>>>
>>>>>             Map(x => x.volgorde, "fvolgorde");
>>>>>
>>>>>             Map(x => x.type, "ftype");
>>>>>
>>>>>             Map(x => x.global, "fglobal");
>>>>>
>>>>>             Map(x => x.machine, "fmachine");
>>>>>
>>>>>             Map(x => x.parameter, "fparameter");
>>>>>
>>>>>         }
>>>>>
>>>>>     }
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>> When I remove everything under public class DCSVMap : ClassMap<DCSV>,
>>>>> the code will run. But when I add it again, the previous error occurs.
>>>>>
>>>>>
>>>>> I can copy the query and try to execute it in the database, but I
>>>>> don't know how to do that.
>>>>>
>>>>> Op donderdag 10 augustus 2017 23:55:27 UTC+2 schreef Gunnar Liljas:
>>>>>>
>>>>>> Is it an NHibernate issue?
>>>>>>
>>>>>> Can you be more specific?
>>>>>>
>>>>>> /g
>>>>>>
>>>>>> On 10 Aug 2017, at 20:03, Ganesh Gebhard <[email protected]> wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I tried to add a new table to the sql database, but it gives an error
>>>>>> no matter what I do.
>>>>>>
>>>>>> So, what are the steps to add a new table to the sql database?
>>>>>>
>>>>>> Thanks in advance.
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "nhusers" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> To post to this group, send email to [email protected].
>>>>>> Visit this group at https://groups.google.com/group/nhusers.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "nhusers" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> Visit this group at https://groups.google.com/group/nhusers.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "nhusers" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at https://groups.google.com/group/nhusers.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/nhusers.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to