0

MonoRailで非同期アクションを使用しようとしていますが、ビューがレンダリングされるとNullReference例外が発生し、これもemtpyビューファイルでテストされています。

また、EndUploadTagsでRenderView( "uploadTags.vm")を呼び出そうとしました。EndUploadTagsでRenderTextを呼び出しても、例外は発生しません。

スタックトレース:

   [NullReferenceException: Object reference not set to an instance of an object.]
   Castle.MonoRail.Framework.Services.DefaultCacheProvider.Get(String key) +163
   Castle.MonoRail.Framework.Views.NVelocity.CustomResourceManager.GetResource(String resourceName, ResourceType resourceType, String encoding) +68
   NVelocity.Runtime.RuntimeInstance.GetTemplate(String name, String encoding) +57
   NVelocity.Runtime.RuntimeInstance.GetTemplate(String name) +82
   NVelocity.App.VelocityEngine.GetTemplate(String name) +47
   Castle.MonoRail.Framework.Views.NVelocity.NVelocityViewEngine.Process(String viewName, TextWriter output, IEngineContext context, IController controller, IControllerContext controllerContext) +564
   Castle.MonoRail.Framework.Services.DefaultViewEngineManager.Process(String templateName, TextWriter output, IEngineContext context, IController controller, IControllerContext controllerContext) +237
   Castle.MonoRail.Framework.Controller.ProcessView() +146
   Castle.MonoRail.Framework.Controller.EndProcess() +1579
   Castle.MonoRail.Framework.BaseAsyncHttpHandler.EndProcessRequest(IAsyncResult result) +141

[MonoRailException: Error processing MonoRail request. Action uploadtags on asyncController vendor]
   Castle.MonoRail.Framework.BaseAsyncHttpHandler.EndProcessRequest(IAsyncResult result) +461
   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +86

これは私のテストコードです:

        private Output output;
        public delegate string Output();

        private string DoNothing()
        {
            return "nothing";
        }

        private string Upload()
        {
            return "upload";
        }

        public IAsyncResult BeginUploadTags(HttpPostedFile xmlFile, Boolean doUpload)
        {
            if (IsPost)
            {
                output = Upload;
                return output.BeginInvoke(ControllerContext.Async.Callback, null);
            }
            output = DoNothing;
            return output.BeginInvoke(ControllerContext.Async.Callback, null);
        }

        public void EndUploadTags()
        {
            var s = output.EndInvoke(ControllerContext.Async.Result);
            PropertyBag["logging"] = s;
        }
4

1 に答える 1

2

これは、MonoRailの古いバージョンのバグです。これはMonoRail2.1RCで動作しますが、試したばかりの古いバージョンでは動作しません。同じnullref例外が発生しました。

これは、リビジョン5688がSubversionでどのように見えたかであり、これが元となっていNullReferenceExceptionます。コードHttpContextはキャッシュにを使用しなくなりました。

public object Get(String key)
{
    if (logger.IsDebugEnabled)
    {
        logger.DebugFormat("Getting entry with key {0}", key);
    }

    return GetCurrentContext().Cache.Get(key);
}

private static HttpContext GetCurrentContext()
{
    return HttpContext.Current;
}
于 2012-10-30T12:51:17.047 に答える