Exception Castle MonoRail具有异步动作视图渲染异常
我试图在MonoRail中使用异步操作,但是当呈现视图时,我得到一个NullReference异常,该异常也使用emtpy视图文件进行了测试 我还尝试在EndUploadTags中调用RenderView(“uploadTags.vm”)。 当我在EndUploadTags中调用RenderText时,我没有得到异常 堆栈跟踪:Exception Castle MonoRail具有异步动作视图渲染异常,exception,asynchronous,action,castle-monorail,nvelocity,Exception,Asynchronous,Action,Castle Monorail,Nvelocity,我试图在MonoRail中使用异步操作,但是当呈现视图时,我得到一个NullReference异常,该异常也使用emtpy视图文件进行了测试 我还尝试在EndUploadTags中调用RenderView(“uploadTags.vm”)。 当我在EndUploadTags中调用RenderText时,我没有得到异常 堆栈跟踪: [NullReferenceException: Object reference not set to an instance of an object.]
[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;
}
这是旧版本MonoRail中的一个bug。它在中工作,但不是在我刚刚尝试的旧版本中,我得到了相同的null ref异常 这就是版本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;
}
这不是问题的真正答案。你只需要问更多的细节,请用评论来回答这样的要求。对不起,我试过了,但我找不到怎么做。也许我的声望太低了?是的,我没有50个rep()。日志的配置如下:container.AddFacility(“Logging”,newloggingfcility(LoggerImplementation.Log4net,“Log4net.config”);请参阅我的更新答案,这与日志无关,但MonoRail版本存在异步操作缺陷。