wpf: XamlWriter and stack overflow

  • Thread starter Thread starter moondaddy
  • Start date Start date
M

moondaddy

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?
 
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
 
Here's one of them:

public object Child
{
get { return _child; }
set { _child = value; }
}
 
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
 
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/library/system.windows.markup.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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top