wpf: XamlWriter and stack overflow

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • moondaddy

    wpf: XamlWriter and stack overflow

    I'm trying to serialize some xaml elements using the XamlWriter and I'm
    getting a stack overflow error because the elements have some public
    properties which get called about a million ( a lot) times. As I step
    through the code the only thing that executes is the getter in these
    properties and I don't know what would be calling them. any ideas on how to
    trouble shoot this?

    --
    moondaddy@newsg roup.nospam


  • Chris Jobson

    #2
    Re: XamlWriter and stack overflow

    I'm trying to serialize some xaml elements using the XamlWriter and I'm
    getting a stack overflow error because the elements have some public
    properties which get called about a million ( a lot) times. As I step
    through the code the only thing that executes is the getter in these
    properties and I don't know what would be calling them. any ideas on how
    to trouble shoot this?
    Just a guess - is there any chance that one of these properties is defined
    in terms of itself, e.g.:

    private int myInt;
    public int MyInt { get { return MyInt; } } // note capital M in last word
    instead of
    public int MyInt { get { return myInt; } } // note small m

    Chris Jobson


    Comment

    • moondaddy

      #3
      Re: XamlWriter and stack overflow

      Here's one of them:

      public object Child
      {
      get { return _child; }
      set { _child = value; }
      }



      "Chris Jobson" <chris.jobson@b tinternet.comwr ote in message
      news:OXLTFb0yIH A.1504@TK2MSFTN GP05.phx.gbl...
      >I'm trying to serialize some xaml elements using the XamlWriter and I'm
      >getting a stack overflow error because the elements have some public
      >properties which get called about a million ( a lot) times. As I step
      >through the code the only thing that executes is the getter in these
      >properties and I don't know what would be calling them. any ideas on how
      >to trouble shoot this?
      >
      Just a guess - is there any chance that one of these properties is defined
      in terms of itself, e.g.:
      >
      private int myInt;
      public int MyInt { get { return MyInt; } } // note capital M in last
      word
      instead of
      public int MyInt { get { return myInt; } } // note small m
      >
      Chris Jobson
      >

      Comment

      • Jon Skeet [C# MVP]

        #4
        Re: wpf: XamlWriter and stack overflow

        On Jun 10, 10:33 pm, "moondaddy" <moonda...@news group.nospamwro te:
        I'm trying to serialize some xaml elements using the XamlWriter and I'm
        getting a stack overflow error because the elements have some public
        properties which get called about a million ( a lot) times.
        You don't get a stack overflow error just because a property is called
        millions of times. You get a stack overflow when you've got recursion
        somewhere - one property calling itself (or A calling B calling A
        etc).

        Have you managed to recover a stack trace? It's not always possible
        with stack overflows, but if you can get one it should show what's
        going on.

        Jon

        Comment

        • Linda Liu[MSFT]

          #5
          RE: wpf: XamlWriter and stack overflow

          Thanks Chris for your help!

          Hi George,

          Generally speaking, the overflow exception occurs in case of a very deep or
          unbounded recursion.

          Please check the code of the XAML elements you would serialize. After you
          find them, make some modifications and the problem should be solved.

          If you need our assistance, please show us the code of the XAML elements.

          For more information on the XMLWriter class, please refer to the following
          MSDN document:
          http://msdn.microsoft.com/en-us/libr....xamlwriter(VS.
          85).aspx

          Hope this helps.

          Sincerely,
          Linda Liu
          Microsoft Online Community Support

          Delighting our customers is our #1 priority. We welcome your comments and
          suggestions about how we can improve the support we provide to you. Please
          feel free to let my manager know what you think of the level of service
          provided. You can send feedback directly to my manager at:
          msdnmg@microsof t.com.

          =============== =============== =============== =====
          Get notification to my posts through email? Please refer to
          Gain technical skills through documentation and training, earn certifications and connect with the community

          ications.

          Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
          where an initial response from the community or a Microsoft Support
          Engineer within 1 business day is acceptable. Please note that each follow
          up response may take approximately 2 business days as the support
          professional working with you may need further investigation to reach the
          most efficient resolution. The offering is not appropriate for situations
          that require urgent, real-time or phone-based interactions or complex
          project analysis and dump analysis issues. Issues of this nature are best
          handled working with a dedicated Microsoft Support Engineer by contacting
          Microsoft Customer Support Services (CSS) at
          http://msdn.microsoft.com/subscripti...t/default.aspx.
          =============== =============== =============== =====
          This posting is provided "AS IS" with no warranties, and confers no rights.


          Comment

          • Chris Jobson

            #6
            Re: XamlWriter and stack overflow

            Here's one of them:
            >
            public object Child
            {
            get { return _child; }
            set { _child = value; }
            }
            That looks fine. I've no other ideas at present - can you post a small code
            sample that demonstrates the problem?

            Chris


            Comment

            Working...