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 7631377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:20:17+00:00 2026-05-31T06:20:17+00:00

I have a bunch of classes that implement cached properties that return collections of

  • 0

I have a bunch of classes that implement cached properties that return collections of data retrieved from a database. The problem I have is if I set breakpoints when debugging VS 2010 appears to execute the property itself in order to display the count of dictionary items.

How can I stop VS from executing the property before it’s ready?
Thanks in advance…

Example that shows the problem:

public class CTest
{
    private ICollection<int> _col = null;

    public ICollection<int> col
    {
        get
        {
            if (this._col == null)
            {
                System.Diagnostics.Debug.Assert(false, "ASSERT!");

                this._col = new Collection<int>();
                this._col.Add(1);
                this._col.Add(2);
                this._col.Add(3);
            }

            return this._col;
        }
    }
}




CTest test = new CTest();

// A breakpoint on this line and no assert will fire
int nCount = test.col.Count;

// A breakpoint on this line and assert will fire
nCount = test.col.Count;
  • 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-31T06:20:19+00:00Added an answer on May 31, 2026 at 6:20 am

    This is caused by automatic property evaluation. The general guidelines for .NET development state that property evaluation should be fast and not cause side-effects. Obviously, things like caching and lazy loading in ORM’s violate this principal in favor of increased usability, but what you’re experiencing is one consequence of this violation.

    To counter this, you need to turn off automatic property evaluation in the debugger options dialog box. See this MSDN link for more information.

    (On an entirely unrelated note, standard .NET conventions call for pascal-cased public members such as properties and functions. Consider capitalizing your property name [Dic instead of dic] and giving it a more descriptive name).

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

Sidebar

Related Questions

We have a bunch of classes that listen for events from the server and
Here is my problem. I have a bunch of Configuration classes that get serialized
Let's say I have a bunch of classes that look something like... class Foo{
In my program, I've got a bunch of classes that will only ever have
I have a web application that contains a bunch of classes in the App_Code
I have a NetBeans project set up with a bunch of source classes and
I have a bunch of classes that I intend to serialize in order to
I have a bunch of classes that all contain a Shared ReadOnly Dictionary. If
I have a bunch of classes that i have to tweak for improved memory
I have a virtual base class and two classes that implement the various methods.

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.