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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:15:08+00:00 2026-05-17T03:15:08+00:00

Visual Studio has thrown a useless exception which I think is caused by the

  • 0

Visual Studio has thrown a useless exception which I think is caused by the fact I have multiple dependency properties in two similar classes with the same name.

The classes are add/edit contact so they share a number of properties, my problem is this.

I can register a property as:

DependencyProperty.Register( /*...*/ );

or:

MyDP.AddOwner( /*...*/ )

The problem is that I have no way of knowing whether the add or edit class will be instantiated first (depends on user choice), since they’re defined as static, I can’t put anything fancy in their initialisation logic… I’m out of ideas that can be self contained within the 2 classes.

So how do I set up the dependency properties in this scenario?

Edit:

Type Initialization Exception: The type initializer for ‘CharterHouseTouchScreenDemo.Views.Membership.AddMembershipView’ threw an exception.

I know that it’s one of the dependency property initialisers because when stepping through it doesn’t even get to the constructor.

also, in this case, they don’t share enough similarities to be the same class. in a nutshell, the only thing they share is the information stored in this dependency property.

Edit 2:

I’m suprised this isn’t better documented, in any medium-large scale applications the chances of accidentally naming a dependency property the same thing are pretty large. Especially for generic things like BackgroundColour, HeadingText, CurrentXYZ…

I always assumed you passed the type of the owner class so that it wouldn’t cause issues like this.

  • 1 1 Answer
  • 3 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-17T03:15:09+00:00Added an answer on May 17, 2026 at 3:15 am

    Not really a kosher answer, but it works:

    #region SubscriptionFee
    
    /// <summary>
    /// SubscriptionFee Dependency Property
    /// </summary>
    public static readonly DependencyProperty SubscriptionFeeProperty =
        DependencyProperty.Register( "SubscriptionFee_2", typeof( decimal ), typeof( EditMembershipViewModel ),
            new FrameworkPropertyMetadata( (decimal)0 ) );
    
    /// <summary>
    /// Gets or sets the SubscriptionFee property. This dependency property
    /// indicates the new subscription fee for the customer.
    /// </summary>
    public decimal SubscriptionFee
    {
        get { return (decimal)GetValue( SubscriptionFeeProperty ); }
        set { SetValue( SubscriptionFeeProperty, value ); }
    }
    
    #endregion SubscriptionFee
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Short version: Why does Visual Studio tell me that the code has thrown a
Visual Studio 2008 has the ability to automatically create unit test stubs. I have
We have a database project in Visual Studio 2008 that has been working great.
Visual Studio has ways to automatically create a method. For example, you could double
I realize that Visual Studio has the /P option to generate preprocessed files, but
Either I'm going mad or the Code Analysis tab in Visual Studio has disappeared
Somehow Visual Studio search has stopped working for me. Anytime I search Entire Solution
With the framework that Visual Studio 2008 has, am I missing anything great by
What are the best code snippets for C#? (using visual studio) VB has a
Several times throughout the course of our current project, the visual studio designer has

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.