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

  • Home
  • SEARCH
  • 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 7440317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:49:59+00:00 2026-05-29T10:49:59+00:00

I have a WPF client application receiving objects via a reference to a remote

  • 0

I have a WPF client application receiving objects via a reference to a remote WCF service. The WCF service references were generated via Visual Studio’s ‘Add Service Reference…’.

I would like to execute a piece of code each time an object received/deserialized from the WCF service. The object needs to already be deserialized so I can read properties/call methods on it. This solution would be global and not something I need to add to every WCF service call.

  • 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-29T10:50:00+00:00Added an answer on May 29, 2026 at 10:50 am

    Starting with Mike’s initial response I was able to come up with the following solution.

    Background

    1. Client pulls data from the server, over a WCF service.
    2. The WCF service reference is generated by Visual Studio with “reuse types in referenced assemblies” so no WCF proxy manipulation can be done.
    3. A property on the Client side app needs to be modified when any property, on any of the objects received from WCF has changed (these objects implement INotifyPropertyChanged)

    Forewarning

    I understand that this breaks some object oriented and responsibility rules, however the solution is so short, so easy, and fits my current and anticipated future needs so it is what I went with. This solution is less practical when there is significant logic that needs to occur on each client-side deserialization.

    [DataContract]
    public class DataTransferObject : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
    
        [OnDeserialized]
        public void OnDeserialized(StreamingContext context)
        {
            dynamic app = Application.Current;
            if(app != null) //Prevents execution on server-side.  This code is meant to only execute at the client
            {
                PropertyChanged += (sender, args) =>
                                       {
                                           app.IsAnythingDirty = true;
                                       };
            }
        }
    }
    

    The keys

    1. The reason this works is the dynamic keyword. You have to use the
      dynamic keyword because the project containing the DTO cannot reference the
      UI project due to a circular reference. If it can’t reference the UI project the compiler does not know about the IsAnythingDirty boolean.
    2. Checking whether Application.Current is null ensures that the code will only run on the client-side, not the server-side.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF application using service references to a WCF service. When doing
In my WPF client, I have a loop that calls a WCF service to
I have a WPF application in VS 2008 with some web service references. For
I have created an application which has a client (WPF) and the Server (WCF),
we have a rich client application written in WPF/WCF and are intending to create
I am developing an application using WPF/MVVM. I have a WCF data service project
I have an internal WPF client application that accesses a database. The application is
I am developing an application in C# WPF which will have Client-Server architecture (Client
I have a desktop client application build under .net 4.0 and WPF. In this
I have a WPF application targetting the .NET 4.0 Client Profile which needs to

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.