1

在控制器中写入响应时出现以下异常:

Object reference not set to an instance of an object.

System.NullReferenceException occurred
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=System.Web
  StackTrace:
       at System.Web.Util.StringUtil.memcpyimpl(Byte* src, Byte* dest, Int32 len)
       at System.Web.Util.StringUtil.UnsafeStringCopy(String src, Int32 srcIndex, Char[] dest, Int32 destIndex, Int32 len)
       at System.Web.HttpWriter.Write(String s)
       at Controllers.DropboxController.<Sync>b__2(BlogUpdaterEventArgs args) in DropboxController.cs:line 78
  InnerException: 

发生异常的代码行是:

BlogUpdater.Execute(htmlPostProvider, args => Response.Write(args.Message));

我的Execute方法在处理时发布消息。Execute 方法签名是:

public static void Execute(IHtmlPostProvider postProvider, BlogUpdaterEventHandler outputMessageCallback)

有时这有效,有时它会引发异常。当它抛出异常时,当我在调试器中检查它时,实际上没有任何明显的设置为 null。args.Message是有效字符串,响应有效,Response.OutputStream 和 Response.OutputStream.CanWrite 也是有效的

关于什么可能是错误的任何想法?

4

0 回答 0