System.TypeLoadException : Could not load type 'AuditEventListener' from assembly 'GolfHandicapManager.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
On Mon, Mar 2, 2009 at 9:33 AM, Ramana Kumar <[email protected]>wrote: > Hi > I am getting the following exception when I am trying to register for > "pre-insert"/"pre-update" Event. > > BTW, I am trying to use the OnPreInsert Event in 2.0.1 to insert CreatedBy, > CreatedOn fields to each AudiatbleEntity. I did looked in the > http://nhforge.org/wikis/howtonh/creating-an-audit-log-using-nhibernate-events.aspx, > however, it uses a seperate table for all the entities, I would like to add > the auditable colums in the same table. > > Question, is this the right way to go about doing it? if so, any pointers > in solving the problem? > Thanks > Ramana > > Exception thrown > ================ > Tests.GolfHandicapManager.Data.GolferRepositoryTests.CanSaveGolfer: > NHibernate.MappingException : Unable to instantiate specified event > (PreUpdate) listener class: AuditEventListener, GolfHandicapManager.Data > ----> System.TypeLoadException : Could not load type 'AuditEventListener' > from assembly 'GolfHandicapManager.Data, Version=1.0.0.0, Culture=neutral, > PublicKeyToken=null'. > StackTrace > ========== > at NHibernate.Cfg.Configuration.SetListeners(ListenerType type, String[] > listenerClasses) > at NHibernate.Cfg.Configuration.DoConfigure(IHibernateConfiguration hc) > at NHibernate.Cfg.Configuration.Configure(XmlReader textReader) > at NHibernate.Cfg.Configuration.Configure(String fileName, Boolean > ignoreSessionFactoryConfig) > at NHibernate.Cfg.Configuration.Configure(String fileName) > at SharpArch.Data.NHibernate.NHibernateSession.ConfigureNHibernate(String > cfgFile, IDictionary`2 cfgProperties) in > C:\MyStuff\Dev\Projects\SharpArchitecture\src\SharpArch\SharpArch.Data\NHibernate\NHibernateSession.cs:line > 139 > at SharpArch.Data.NHibernate.NHibernateSession.Init(ISessionStorage > storage, String[] mappingAssemblies, AutoPersistenceModel > autoPersistenceModel, String cfgFile, IDictionary`2 cfgProperties, String > validatorCfgFile) in > C:\MyStuff\Dev\Projects\SharpArchitecture\src\SharpArch\SharpArch.Data\NHibernate\NHibernateSession.cs:line > 62 > at SharpArch.Data.NHibernate.NHibernateSession.Init(ISessionStorage > storage, String[] mappingAssemblies, AutoPersistenceModel > autoPersistenceModel, String cfgFile) in > C:\MyStuff\Dev\Projects\SharpArchitecture\src\SharpArch\SharpArch.Data\NHibernate\NHibernateSession.cs:line > 48 > at Tests.GolfHandicapManager.Data.GolferRepositoryTests.SetUp() in > C:\Documents and Settings\rkumar\My Documents\Visual Studio > 2008\Projects\GolfHandicapManager\tests\GolfHandicapManager.Tests\GolfHandicapManager.Data\GolferRepositoryTests.cs:line > 21 > --TypeLoadException > at System.Reflection.Assembly._GetType(String name, Boolean throwOnError, > Boolean ignoreCase) > at System.Reflection.Assembly.GetType(String name, Boolean throwOnError) > at NHibernate.Util.ReflectHelper.TypeFromAssembly(AssemblyQualifiedTypeName > name, Boolean throwOnError) > at NHibernate.Cfg.Configuration.SetListeners(ListenerType type, String[] > listenerClasses) > > > Hibernate.cfg.xml > ================== > > <event type="pre-update"> > <listener class="AuditEventListener, GolfHandicapManager.Data"/> > </event> > <event type="pre-insert"> > <listener class="AuditEventListener, GolfHandicapManager.Data"/> > </event> > > </session-factory> > > AuditEventListener.cs > ===================== > public class AuditEventListener : IPreUpdateEventListener, > IPreInsertEventListener > { > public AuditEventListener() { } > public bool OnPreInsert(PreInsertEvent e) > { > IAuditableEntity aEntity = e.Entity as AuditableEntity; > if (aEntity == null) > { > return false; > } > aEntity.CreatedOn = DateTime.Now; > aEntity.CreatedBy = "Some User"; > aEntity.UpdatedOn = DateTime.Now; > aEntity.UpdatedBy = "Some User"; > return false; > } > public bool OnPreUpdate(PreUpdateEvent e) > { > IAuditableEntity aEntity = e.Entity as AuditableEntity; > if (aEntity == null) > { > return false; > } > aEntity.UpdatedOn = DateTime.Now; > aEntity.UpdatedBy = "Some User"; > return false; > } > } > AuditableEntity.cs > ===================== > public class AuditableEntity : Entity, IAuditableEntity > { > public virtual DateTime CreatedOn { get; set; } > public virtual string CreatedBy { get; set; } > public virtual DateTime UpdatedOn { get; set; } > public virtual string UpdatedBy { get; set; } > } > public interface IAuditableEntity > { > DateTime CreatedOn { get; set; } > string CreatedBy { get; set; } > DateTime UpdatedOn { get; set; } > string UpdatedBy { get; set; } > } > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
