Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 985749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:12:41+00:00 2026-05-16T05:12:41+00:00

I get an odd intermittent error when trying to write a Diagnostics.Trace message from

  • 0

I get an odd intermittent error when trying to write a Diagnostics.Trace message from an assembly used by an ASP.NET application. It’s .NET 3.5 on IIS7.

The code setup is that when web.config has debug specified I add an instance of HttpResponseTraceListener to System.Diagnostics.Trace.Listeners. I’m doing it that way so in my other assembly I can write out debug information when running on a test server that I’m not set up to debug using visual studio. So in my other assembly I use System.Diagnostics.Trace.WriteLine to output information, which then also gets written to the response stream (inline, but for my purpose that is just fine).

The error is:

Object reference not set to an instance of an object.

The relevant stack information is:

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 System.Web.HttpResponse.Write(String s)
at SSO.HttpResponseTraceListener.Write(String message) in HttpResponseTraceListener.cs:line 23
at SSO.HttpResponseTraceListener.WriteLine(String message) in HttpResponseTraceListener.cs:line 30
at System.Diagnostics.TraceInternal.WriteLine(String message)

The TraceListener class is as follows:

public class HttpResponseTraceListener : TraceListener
{
    public System.Web.HttpResponse Response { get; private set; }
    public HttpResponseTraceListener(System.Web.HttpResponse response)
    {
        Response = response;
    }
    public override void Write(string message)
    {
        if (!string.IsNullOrEmpty(message)
         && null != Response
         && null != Response.OutputStream
         && Response.OutputStream.CanWrite)
        {
            Response.Write(System.Web.HttpUtility.HtmlEncode(message));
        }

    }

    public override void WriteLine(string message)
    {
        this.Write(message);
        Response.Write("<BR />");
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:12:42+00:00Added an answer on May 16, 2026 at 5:12 am

    Looks like the problem was that the TraceListeners never were detached. So each time I hit the page I added another one. And each time I wrote to Diagnostics.Trace it would write to all that were attached. But for some the Response object was not able to be written to.

    To fix it I added code to not write if there was an exception. And also added code to remove the listener when the page was done loading.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When trying to install a package in R I get the following odd error
I'm trying to (cross-)compile node.js and I get this odd error that appears to
I'm seeing an odd behavior with trying to get seconds since epoch in objective
I get an odd error while batching data to Azure table storage. I have
I am trying to get only the odd or only the even index of
Possible Duplicate: Getting odd/even part of a sequence with LINQ How can I get
I'm running into an odd issue retrieving printer port addresses. When I get all
Get class from div inside an li and add to the same li. The
The cipher code actually works; it's just that I get some odd three digit
I recently ran into an odd issue where I'd get a const_iterator instead of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.