.Net Software Development Blog
| | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|
| 31 | 1 | 2 | 3 | 4 | 5 | 6 | | 7 | 8 | 9 | 10 | 11 | 12 | 13 | | 14 | 15 | 16 | 17 | 18 | 19 | 20 | | 21 | 22 | 23 | 24 | 25 | 26 | 27 | | 28 | 29 | 30 | 1 | 2 | 3 | 4 | | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
Search
Navigation
Categories
Blogroll
|

Tuesday, June 02, 2009
IPreUpdateEventListener Registration
Ayende has a great blog post about using IPreUpdateEventListeners. I couldn’t get the event to fire for some reason. I tried registering the events in the config file like this:
<event>
<listener class="MyNamespace.AuditEventListener, MyAssembly"/>
</event>
<event>
<listener class=”MyNamespace.AuditEventListener, MyAssembly"/>
</event>
For some reason the events were not firing. The only thing I could figure was something in my namespace or assembly was incorrect but I checked everything multiple times and could never get it to work. Eventually I had to pass the registration through to the config file while setting up my SessionFactory this:
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
cfg.EventListeners.PreUpdateEventListeners =
new IPreUpdateEventListener[] {new AuditEventListener()};
cfg.EventListeners.PreInsertEventListeners =
new IPreInsertEventListener[] { new AuditEventListener() };
_sessionFactory = cfg.BuildSessionFactory();
I’m still not sure what the problem was, still betting on a namespace or assembly naming issue. I’ll add it to my list of things to look at when I get some time.
Tuesday, June 02, 2009 4:04:35 AM (Central Daylight Time, UTC-05:00)