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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:59:15+00:00 2026-05-28T00:59:15+00:00

I have a very simple class that has a single property and which inherits

  • 0

I have a very simple class that has a single property and which inherits INotifyPropertyChanged:

class SimpleClass:INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
    private string _property;
    public string Property
    {
        get { return _property; }
        set
        {
            _property = value; 
            PropertyChanged(this, new PropertyChangedEventArgs"Property"));
        }
    }
}

I try to instantiate a SimpleClass object in the constructor for a WPF Window but I get the following TargetInvocationException: “Exception has been thrown by the target of an invocation”.
If I remove the INotifyPropertyChange inheritance (and any reference to the PropertyChanged event) then I don’t get the error and my project runs without any problems. Any ideas why?

Cheers

  • 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-28T00:59:16+00:00Added an answer on May 28, 2026 at 12:59 am

    You aren’t checking for null on PropertyChanged.

    if nobody is listening, then it will be null. most people protect for the event listeners to change during the event, as well:

    var listeners = PropertyChanged;
    if (listeners != null)
        listeners(this, new PropertyChangedEventArgs("Property");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a very simple class that has a method called getThumbUrl() but
Let's say I have a very simple PrototypeJS class that looks like this: var
i'm missing something fundamental here. i have a very simple custom class that draws
Very simply put: I have a class that consists mostly of static public members,
I have this very simple C++ class: class Tree { public: Node *head; };
I have a very simple code: package mygame; public class RunGame { public static
I have a legacy piece of software that has a single manager which controls
Let's say we have very simple Java class MyClass . public class MyClass {
I have a class called Profile that has some simple properties and then it
I have a very simple class with only one field member (e.g. String). Is

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.