Solution was found ... full details here
http://stackoverflow.com/a/16378727/363888
On Saturday, 27 April 2013 16:54:24 UTC+1, Scott Findlater wrote:
>
> Hi All,
>
> I am currently using Envers within a C# WebApi project. Windsor is used
> for IoC.
> I have a custom RevisionEntity which add a User property to audit the user
> who has made the data change.
>
> To ensure all configurations were correct I started off with a "simple
> string here" being added in the NewRevision method;
> public class AuditRevisionListener : IRevisionListener
> {
> public void NewRevision(object revisionEntity)
> {
> ((AuditRevision)revisionEntity).User = "Simple string here;
> }
> }
>
> and all persisted as expected.
>
> Next step is to achieve a full User object to which I need to obtain the
> UserService;
> public class AuditRevisionListener : IRevisionListener
> {
> public void NewRevision(object revisionEntity)
> {
> var userServices =
> (IUserServices)GlobalConfiguration.Configuration.DependencyResolver.GetService(typeof(IUserServices));
>
> var user = userServices.GetRequestingUser();
>
> ((AuditRevision)revisionEntity).User = user;
> }
> }
>
> However, the DependencyResolver.GetService is throwing the error;
> "Cannot access a disposed object. Object name: 'Scope cache was already
> disposed. This is most likely a bug in the calling code.'. "
>
> I have also tried ctor injection during the Envers configuration but this
> also resulted with the above error;
> var auditConfiguration = new FluentConfiguration();
> var userServices =
> (IUserServices)GlobalConfiguration.Configuration.DependencyResolver.GetService(typeof(IUserServices));
> auditConfiguration.SetRevisionEntity<AuditRevision>(r => r.Id,
> r => r.Timestamp, new AuditRevisionListener(userServices));
> auditConfiguration.Audit(GetAuditEntities());
> configuration.IntegrateWithEnvers(auditConfiguration);
>
> For clarity, I use the DependencyResolver.GetService within an
> ActionFilter and all resolves correctly.
>
> Does anyone have any ideas about what I am missing with either my Envers
> configuration or Windsor configuration?
>
--
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 http://groups.google.com/group/nhusers?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.