2012-10-30 5 views
0

MonoRail에서 비동기 작업을 사용하려고하지만 뷰가 렌더링 될 때 Emptpy보기 파일로 테스트 한 NullReference 예외가 발생합니다.성 MonoRail with asynchronous action보기 렌더링 예외

또한 EndUploadTags에서 RenderView ("uploadTags.vm")를 호출하려고했습니다. EndUploadTags에서 RenderText (s)를 호출 할 때 예외가 발생하지 않습니다.

스택 트레이스 :

[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; 
     } 

답변

2

이 모노레일의 이전 버전에서 버그가. 그것은 MonoRail 2.1 RC에서 작동하지만, 방금 시도한 이전 버전에서는 그렇지 않습니다. 동일한 null ref 예외가 있습니다.

Subversion에서 수정 버전 5688이 보이는데 이는 NullReferenceException의 출처입니다. code은 더 이상 캐시에 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; 
} 
+0

이것은 실제 질문이 아닙니다. 당신은 단지 더 많은 세부 사항을 요구합니다, 그런 요구에 대한 의견을 사용하십시오 – greydet

+0

미안 해요, 시도했지만 어떻게 할 수 없습니다. 저의 저임 한사람으로 제한 될까요? 예, 50 명의 담당자가 없습니다 (http://meta.stackexchange.com/questions/117496/missing-add-comment-link-button). –

+0

로깅은 다음과 같이 구성됩니다. container.AddFacility ("logging", 새 LoggingFacility (LoggerImplementation.Log4net, "log4net.config")); – ZxCvBnM