views:

54

answers:

1

I have a Windows service which has a timer and in the timer_Elapsed event handler a method from another component will be called which is supposed to look into db and get or update some records.This process will happen every 2 minutes.I used nhibernate for data access in the component. When I run the method from unit test it is working fine which means the configurations and mappings are correct, but from windows service I get this exception:

FluentNHibernate.Cfg.FluentConfigurationException was caught
  Message="An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.\r\n\r\n"
  Source="FluentNHibernate"
  StackTrace:
       at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 121
 InnerException: NHibernate.MappingException
       Message="Could not configure datastore from input stream (XmlDocument)"
       Source="NHibernate"
       StackTrace:
            at NHibernate.Cfg.Configuration.LogAndThrow(Exception exception)
            at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name)
            at NHibernate.Cfg.Configuration.AddDocument(XmlDocument doc, String name)
            at NHibernate.Cfg.Configuration.AddDocument(XmlDocument doc)
            at FluentNHibernate.PersistenceModel.Configure(Configuration cfg) in d:\Builds\FluentNH\src\FluentNHibernate\PersistenceModel.cs:line 265
            at FluentNHibernate.Cfg.FluentMappingsContainer.Apply(Configuration cfg) in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentMappingsContainer.cs:line 141
            at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg) in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\MappingConfiguration.cs:line 64
            at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 112
       InnerException: System.TypeInitializationException
            Message="The type initializer for 'NHibernate.Util.TypeNameParser' threw an exception."
            Source="NHibernate"
            TypeName="NHibernate.Util.TypeNameParser"
            StackTrace:
                 at NHibernate.Util.TypeNameParser.Parse(String type, String defaultNamespace, String defaultAssembly)
                 at NHibernate.Cfg.ClassExtractor.ClassEntry..ctor(String extends, String className, String entityName, String assembly, String namespace)
                 at NHibernate.Cfg.ClassExtractor.GetClassEntries(XmlDocument document)
                 at NHibernate.Cfg.MappingsQueue.AddDocument(NamedXmlDocument document)
                 at NHibernate.Cfg.Configuration.AddDocumentThroughQueue(NamedXmlDocument document)
                 at NHibernate.Cfg.Configuration.AddXmlReader(XmlReader hbmReader, String name)
                 at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name)
            InnerException: System.Threading.ThreadAbortException
                 Message="Exception of type 'System.Threading.ThreadAbortException' was thrown."
                 InnerException: 

Here is the code in timer_elapsed event handler:

private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)


   {
        lock (processLock)
        {
            DoWorkComponent component= new DoWorkComponent ();
            component.DoWorkMethod();
        }
    }

Does anybody know how this can be fixed? Do I need to have different settings?

Thanks in Advance,

Sacha

A: 

Problem solved. The error was related to the user account that runs the service:

http://groups.google.ca/group/fluent-nhibernate/browse_thread/thread/bafd5dddea909eb?hl=en

Thanks, Sacha

Sacha