1

次の例外が表示されます。

System.NullReferenceException: オブジェクト参照がオブジェクトのインスタンスに設定されていません。System.Web.Util.StringUtil.memcpyimpl (Byte* src, Byte* dest, Int32 len) System.Web.Util.StringUtil.UnsafeStringCopy (String src, Int32 srcIndex, Char[] dest, Int32 destIndex, Int32 len) でSystem.Web.HttpWriter.Write(String s) で System.Web.HttpResponse.Write(String s) で

私はすでに、応答しているコンテキストについて次のチェックを行っています。

return !(context == null || context.Response == null ||
    context.Response.OutputStream == null ||
    !context.Response.OutputStream.CanWrite);

これを引き起こしている可能性があることを誰かが示唆できますか?

4

5 に答える 5

1

それがエラーの場所だと確信していますか?HttpResponse の Write メソッドから例外が発生しているようです。

于 2009-02-19T19:27:00.397 に答える
0

あなたのエラーは別の場所にあると思いますが、この式をネガなしでもう少し直接的に書くことをお勧めします。

return context != null && context.Response != null &&
    context.Response.OutputStream != null &&
    context.Response.OutputStream.CanWrite;
于 2009-02-19T19:31:52.400 に答える
0

null オブジェクトを実際にバッファー IE に書き込もうとすると、これが発生する可能性があります。

context.Response.OutputStream.Write(null, 0, 0);

また、次のように表すこともできます...

return (context != null && context.Response != null &&
    context.Response.OutputStream != null &&
    context.Response.OutputStream.CanWrite);
于 2009-02-19T19:33:52.553 に答える
0

なぜこれらすべてのチェックに煩わされるのでしょうか? 出力ストリームに書き出すだけで完了しないのはなぜですか?

また、ASP.NET 処理パイプラインのどこでこの呼び出しが行われているのでしょうか?

于 2009-02-19T19:26:19.493 に答える