Attempting to profile Orchard using NHProf

Topics: Troubleshooting
Aug 25, 2011 at 7:08 PM
Edited Aug 25, 2011 at 7:08 PM

This may be more a question for NHProf than Orchard, but...

I am trying to profile Orchard using NHProf, but I am getting this exception - 

Attempt by security transparent method 'Orchard.Web.MvcApplication.Application_Start()' to access security critical method 'HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize()' failed.

Anyone else experienced/found a fix for this? I added a reference to the HibernatingRhinos.Profiler.Appender.v4.dll, and added the .Initialize() line to the Application_Start() event handler.

Subquestion - right now I am just trying to profile, period, but long term, it would probably make more sense to put the profiler initialization code into a module, rather than the global.asax of Orchard.Web...is there an "app startup" event on any Orchard objects that I am overlooking?

 

Thanks!

Coordinator
Aug 25, 2011 at 7:13 PM

Are you running in full trust?

Aug 25, 2011 at 7:25 PM

Yup, running in full trust.

Coordinator
Aug 25, 2011 at 8:33 PM

If you want to see SQL logs you can use http://orchardproject.net/gallery/List/Modules/Orchard.Module.Four2n.MiniProfiler

I already saw this error in the discussion forums, and it was solved by adding some Security attribute in the assembly.cs.

If you want to register something when a tenant is started, you just need to implement  IOrchardShellEvents

Aug 25, 2011 at 9:35 PM

Thanks, Sebastien! On all accounts. The post you saw was here.

I kept thinking it was specific to nhprof, so I never searched the forums without that in the string.