turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 156 forks source link

Odd NullReferenceException #274

Closed berniezhao closed 8 years ago

berniezhao commented 8 years ago

I deployed the app to IIS but run into a NullReferenceException.

I was able to nail down to this line in ResponseFilter.cs file:

if (m_streamIsCompressed || (m_stagingBuffer.Length == 0 && buffer.Length >= 2 && buffer[0] == 31 && buffer[1] == 139))
{
    DebugHelpers.WriteLine("ResponseFilter::Write -- skipping compressed content");
    m_streamIsCompressed = true;
    m_outputStream.Write(buffer, offset, count);
    return;
}

Here the m_stagingBuffer is null.
I can't reproduce it on my local dev machine, only on the deployed server.

Any hint is appreciated!

berniezhao commented 8 years ago

The callstack is interesting. Line 178 of Flush() is supposed to call the original filter. Why it came back to ResponseFilter again? Thanks.

i18n.dll!i18n.ResponseFilter.Write(byte[] buffer, int offset, int count) Line 66    C#
i18n.dll!i18n.ResponseFilter.Flush() Line 178   C#
System.Web.dll!System.Web.HttpWriter.FilterIntegrated(bool finalFiltering, System.Web.Hosting.IIS7WorkerRequest wr) Unknown
System.Web.dll!System.Web.HttpResponse.FilterOutput()   Unknown
System.Web.dll!System.Web.HttpApplication.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   Unknown
System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step, ref bool completedSynchronously)  Unknown
System.Web.dll!System.Web.HttpApplication.PipelineStepManager.ResumeSteps(System.Exception error)   Unknown
System.Web.dll!System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext context, System.AsyncCallback cb)  Unknown
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest wr, System.Web.HttpContext context)    Unknown
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags) Unknown
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags)   Unknown
[AppDomain Transition]  
berniezhao commented 8 years ago

Solved the problem. It turns out the the filter has been configured twice thus being chained to each other.