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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:45:36+00:00 2026-05-19T01:45:36+00:00

I am using directions from here: http://msdn.microsoft.com/en-us/library/ms257351(VS.80).aspx to create a managed event class. Here’s

  • 0

I am using directions from here: http://msdn.microsoft.com/en-us/library/ms257351(VS.80).aspx to create a managed event class. Here’s the code that I wrote:

[ManagementEntity]
[InstrumentationClass(InstrumentationType.Event)]
public class MyEvent
{
    [ManagementKey]
    public string ID { get; set; }
    [ManagementEnumerator]
    static public IEnumerable<MyEvent> EnumerateInstances()
    {
        var e = new MyEvent() { ID = "9A3C1B7E-8F3E-4C54-8030-B0169DE922C6" };
        return new MyEvent[] { e };
    }
}

class Program
{
    static void Main(string[] args)
    {
        var thisAssembly = typeof(Program).Assembly;
        var wmi_installer = new AssemblyInstaller(thisAssembly, null);
        wmi_installer.Install(null);
        wmi_installer.Commit(null);

        InstrumentationManager.RegisterAssembly(thisAssembly);

        Console.Write("Press Enter...");
        Console.ReadLine();
        var e = new MyEvent() { ID = "A6144A9E-0667-415B-9903-220652AB7334" };
        Instrumentation.Fire(e);

        Console.Write("Press Enter...");
        Console.ReadLine();
        wmi_installer.Uninstall(null);
    }

}

I can run a program, and it properly installs. Using wbemtest.exe I can browse to the event, and “show mof”:

[dynamic: ToInstance, provider("WmiTest, 
      Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")]
class MyEvent
{
    [read, key] string ID;
};

Notice, the class does not inherit from __ExtrinsicEvent, which is weird…

I can also run select * from MyEvent, and get the result. Instrumentation.Fire() also returns no error. However, when I’m trying to subscribe to event using “Notification Query” option, I’m getting 0x80041059

Number: 0x80041059

Facility: WMI

Description: Class is not an event class.

What am I doing wrong, and is there a correct way to create managed WMI event?

  • 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-19T01:45:37+00:00Added an answer on May 19, 2026 at 1:45 am

    After some digging, I figured out what happened: apparently in framework 4, there has been a second “branch” of WMI classes and attributes introduced, which interferes with classic ones. All the sample code I found on the internet is written with .NET 2.0 WMI support in mind. I have not found a way with .NET 4 classes to inherit a class from __Event or __ExtrinsicEvent.

    It has been very annoying to find that Microsoft introduced two incompatible branches of code into the same namespace, which not only don’t work with each other, but they break each other’s functionality.

    At any rate, what I needed to do in order to fix the issue was essentially making sure my app is using .NET 2 code:

    • completely get rid of DefaultManagementInstaller derived class inside wmi assembly. Use DefaultManagementProjectInstaller.
    • use Instrumentation.RegisterAssembly instead of InstrumentationManager.RegisterAssembly
    • do some manual cleanup of WMI namespace on Uninstall(), since wmi classes are not properly removed from the namespace with .NET 2 api.
    • cope with the fact that it is impossible to make a field to be a [key] with .NET 2 api
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user input form here: http://www.7bks.com/create (Google login required) When you first
I stumbled across this youtube video here http://www.youtube.com/watch?v=Ha5LficiSJM that demonstrates someone doing color detection
I'm trying to develop a simple shopping cart and using http://jqueryui.com/demos/droppable/#photo-manager as the base.
I built an iPhone toolchain on Ubuntu based on the directions at http://www.saurik.com/id/4 .
I've been trying to switch from using PerlSetEnv to using custom configuration directives .
I installed Ruby and Ruby on Rails yesterday on Vista 32bit using the directions
here is my code - I've tried using the google maps api and other
This page http://winteradagency.com/Arvin/incentives/lenders.htm looks good in all browsers except IE6. The thing that is
This is my first attempt at using JSCookMenu and its homepage ( http://jscook.yuanheng.org/JSCookMenu/ )
I am attempting to pull some information from my tnsnames file using regex. I

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.