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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:15:27+00:00 2026-05-23T16:15:27+00:00

AA, I want to add a custom property to a WMi Object’s Propert Collection.

  • 0

AA,

I want to add a custom property to a WMi Object’s Propert Collection. So that whenever i retrieve the properties of that object, i get the custom added property as well. Specifically speaking lets see the following code.

foreach (ManagementObject WebSite in WebSitesCollection)
        {
            if (WebSite.Properties["Name"].Value.ToString().Contains(appPoolName))
            {
                foreach (PropertyData propertyData in WebSite.Properties)
                {
                    try
                    {

                        HttpContext.Current.Response.Write(propertyData.Name + "  " + propertyData.Value + "<br/>");
                        if (propertyData.Name.Equals("Enable32BitAppOnWin64"))
                        {
                            AppPoolx.SetPropertyValue("Enable32BitAppOnWin64", true);
                            AppPoolx.Put(); return true;
                        }
                        else
                        {
                         AppPoolx.Properties.Add("Enable32BitAppOnWin64", true);
                          AppPoolx.Put(); return true;
                        }

                    }
                    catch (Exception ex1)
                    {
                        HttpContext.Current.Response.Write("Error Ocurred while Setting Property: " + ex1.Message + "<br />");
                        break;
                    }
                }
            }

        }

But the AppPoolx.Properties.Add("Enable32BitAppOnWin64", true); returns error

Operation is not valid due to current state of the object.

I was wondering whether it was even possible to add a custom property to the WMi object. If what is this Add() function for?

In any case, what is the correct procedure of add a “Custom Property to a WMI Object.”

Please do not suggest that i may store in DB.

Regards

Steve

  • 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-23T16:15:28+00:00Added an answer on May 23, 2026 at 4:15 pm

    WMI Objects are basically com objects, much like a C# object those objects are populated by the code at the other end.

    For you to add this custom property you would have to have the functionality in the code at the other end to store the object data for your custom property.

    The add property method you’re calling is not valid for all (pretty much most) com objects that are returned by WMI API’s this is likely your problem, i understand that this is something to do with how the objects from WMI calls are marshalled from the com component in which they are called from.

    So in short:
    This is not likely possible.

    A more correct approach would be to determine the actual type of the object you are working with and set a property value on a property that is writable for the object then push that back to the WMI API.

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

Sidebar

Related Questions

Is it possible to add a custom property to an object that is part
I have a view that I want to add some custom drawing to. I
I have created a user control, and now I want to add custom properties
I want to add a custom attribute / property into the manifest file, and
I want to add custom typed properties to a webcontrol, like for example EditRowStyle
I have a custom property descriptor that I use to support flattening object hierarchies.
I have a set of custom PropertyDescriptor that I want to add categories too
I want to add a custom property to a button in window form. Currently
I am creating a custom control and i want to add some properties in
Couldn't find any related resources I want to add a custom property to my

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.