After some more digging, I've tracked the problem down to the fact
that HttpContext.Current is null.  Somehow, Context (in the
OnEndRequest method in my global application) is still non-null, but
if I attempt to remove the scope from there, it tells me that it is
not the currently registered scope.  This works fine when compiling in
VS2010, but not under mono in Windows or Linux.  As I'm not an expert
in ASP.NET and Mono, I'm at a standstill with async methods until I
can figure this out.

Perhaps I could ask everyone a different question: I can merely check
to see if HttpContext.Current is null and then skip disposing of the
scope if it is.  Will this leave open connections to the database or
have performance or other implications if I don't dispose of the
correct scope?

Thanks for your help,
Brian

On Jun 14, 4:04 pm, bluesliverx <[email protected]> wrote:
> Hello all,
>
> No matter what I try, I can't seem to get the hybrid web scope working
> with an asynchronous action when using Mono (tested on 2.6.1, 2.6.3,
> and 2.6.4).  Each time I get a NullRefEx in either the OnEndRequest
> method or the SessionScopeWebModule.  Here is the stacktrace running
> locally on a windows machine using XSP2:
>
> System.NullReferenceException: Object reference not set to an instance
> of an object
>   at [MyApp].Global.OnEndRequest (System.Object sender,
> System.EventArgs e) [0x00000] in <filename unknown>:0
>   at (wrapper delegate-invoke)
> System.EventHandler:invoke_void__this___object_EventArgs
> (object,System.EventArgs)
>   at (wrapper delegate-invoke)
> System.EventHandler:invoke_void__this___object_EventArgs
> (object,System.EventArgs)
>   at (wrapper delegate-invoke)
> System.EventHandler:invoke_void__this___object_EventArgs
> (object,System.EventArgs)
>   at System.Web.HttpApplication.PipelineDone () [0x0001c] in C:\cygwin
> \tmp\monobuild\build\BUILD\mono-2.6.4\mcs\class\System.Web\System.Web
> \HttpApplication.cs:1106
>
> Here is the same stack trace using mod_mono on Ubuntu, notice on this
> one I was using the SessionScopeWebModule:
>
> System.NullReferenceException: Object reference not set to an instance
> of an object
>   at Castle.ActiveRecord.Framework.SessionScopeWebModule.OnEndRequest
> (System.Object sender, System.EventArgs e) [0x00000] in <filename
> unknown>:0
>   at (wrapper delegate-invoke)
> System.EventHandler:invoke_void__this___object_EventArgs
> (object,System.EventArgs)
>   at System.Web.HttpApplication.PipelineDone () [0x00000] in <filename
> unknown>:0
>
> I tried both methods (writing my own OnBegin/OnEndRequest methods and
> SessionScopeWebModule) since I thought it may at first have been the
> module causing the problem.
>
> The asynchronous action is a simple example:
>
>         public class TasksController : ARSmartDispatchController {
>                 public TasksController()
>                         : base() {
>                         asynctestTask = AsyncTestTaskRun;
>                 }
>                 private delegate string AsyncTestTask();
>                 private readonly AsyncTestTask asynctestTask;
>                 private string AsyncTestTaskRun() {
>                         System.Threading.Thread.Sleep(250);
>                         return "Async Test Finished Successfully";
>                 }
>
>                 public IAsyncResult BeginAsyncTest() {
>                         return 
> asynctestTask.BeginInvoke(ControllerContext.Async.Callback,
> ControllerContext.Async.State);
>                 }
>
>                 public void EndAsyncTest() {
>                         Flash["message"] =
> asynctestTask.EndInvoke(ControllerContext.Async.Result);
>                         RedirectToAction("index");
>                 }
>         }
>
> Any ideas on this one?  I've tried many things to get this working,
> and I do have the HybridWebThreadScopeInfo configured on my
> activerecord:
>   <activerecord isWeb="true"
> threadinfotype="Castle.ActiveRecord.Framework.Scopes.HybridWebThreadScopeIn 
> fo,
> Castle.ActiveRecord">
>      ....
>   </activerecord>
>
> Thanks!
> -Brian

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en.

Reply via email to