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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:30:09+00:00 2026-06-02T03:30:09+00:00

Using a PrivateObject , I’m trying to create an instance of the ItemChange class

  • 0

Using a PrivateObject, I’m trying to create an instance of the ItemChange class (found here). Looking through the debugger as well as the object browser in Visual Studio 2008 I can’t seem to find anything related to the ItemId property other than a setter. Below is the code I am using.

var itemChange = new PrivateObject(typeof(ItemChange));

itemChange.SetFieldOrProperty("ChangeType", _fixture.CreateAnonymous<ChangeType>());
itemChange.SetFieldOrProperty("ItemId", _fixture.CreateAnonymous<ItemId>());

The error I receive is:

System.MissingMethodException : Method 'Microsoft.Exchange.WebServices.Data.ItemChange.ItemId' not found.

I’ve tried variations of BindingFlags, however nothing seems to help. How can I set a property that has no setter and only a getter?

Edit

Regarding my comments, the other inline class that I can create a PrivateObject object instance and set the ItemId is the ItemEvent class (found here). This class was easy because when I was debugging and added the class to my watch list I could see itemId as a private variable. However, performing the same steps on the ItemChange class I cannot find any traces of an ItemId field other than the property itself that only has a setter. This is where I’m stumped on how to set this property.

Lastly, I don’t have access to a tool that would allow me to decompile the class and see what is what.

  • 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-06-02T03:30:10+00:00Added an answer on June 2, 2026 at 3:30 am

    If the property you are trying to set is read-only and not backed by any underlying private field, then you can’t actually set it. For example, if you had the following property:

    public string ItemId
    {
      get 
      {
        return "Test";
      }
    }
    

    nothing you do is ever going to set this property to another value. If you don’t see an obvious backing field when you look through the object’s fields in the debugger and/or reflection, this is likely the situation.

    In this case, if I had to make a guess, I would say that ItemId is probably a shortcut property that simply returns this.Item.Id.

    EDIT:

    I was partly true. According to dotPeek, ItemChange.ItemId just returns Change.id, appropriately typecast. If Change.serviceObject has a value, than Change.id returns Change.serviceObject.GetId(), otherwise it returns Change.id. Which of those is appropriate in your case depends on the kind of change you’re talking about, per MSDN:

    Item is null when the ChangeType property has a value of either ChangeType.Delete or ChangeType.ReadFlagChange.

    Effectively, the implementation of Change and ItemChange does something like this:

    public class Base 
    {
      private Thing thing;
      private BaseId id;
    
      internal BaseId Id
      {
        get
        {
          return this.thing == null ? this.id : this.thing.GetId();
        }
      }
    }
    
    public class Child
    {
      public ChildId ChildId
      {
        get 
        { 
          return (ChildId) this.Id; 
        }
      }
    }
    

    In the actual Change implementation, the object field is a ServiceObject named serviceObject, which has a GetId() method that returns a ServiceId, and there is also an id field of type ServiceId. To get your ItemChange object’s ItemId property set, you need to set one or the other of those internal fields on the object’s base class (the serviceObject field takes precedence if it’s set.)

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

Sidebar

Related Questions

I'm trying to create a method using an expression tree that returns an object,
Using dotnet 2.0. Can the following code be improved in style ? private object
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
I want to access a static JavaFX class member from Java using the Javafx
I'm trying to use SUT Factory 'pattern' to create my SUT. Given the SUT
I'm trying to do web service using android. I created the web service using
I have developed an object pool and cannot seem to do it without using
Will the following code result in a deadlock using C# on .NET? class MyClass
I am using reflection and WSDL to call web services on the fly through
Is there a difference between using a lock object that is declared as a

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.