Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / October 2004

Tip: Looking for answers? Try searching our database.

WMI: Using ManagementClass.GetInstances()

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SlimFlem - 27 Oct 2004 02:19 GMT
Hi.

I am trying to instrument an object that gets loaded into ASP.NET Cache
during Windows_OnAuthenticate() in global.asax.  I have properly put in place
all of the required instrumentation code for both the instrumented class and
done the proper install with installutil.exe.  I used CIM Viewer to verify my
schema was published.

My object appears to be published without a problem...meaning no Exception
is thrown when calling Instrumentation.Publish().  When writing a command
line tool to connect to my published objects using:

ManagementClass wmi = new
ManagementClass(@"\\.\root\InventoryMgmt:ArtComPrincipal")

and then calling wmi.GetInstances() in a for loop, I get an exception of
type InvalidOperationException thrown.  I really don't understand why this
is.  Is there something different about doing this sort of thing when placing
instrumented objects in ASP.NET Cache?

This code is exactly the same from a console app I wrote this evening and it
works fine:

WMIObject obj = new WMIObject();
WMIObject.PublishToWMI(obj);

ManagementClass wmi = new ManagementClass(@"\\.\root\SlimFlem:WMIObject");

foreach (ManagementObject mobj in wmi.GetInstances())
{
   Console.WriteLine(mobj.Properties["Prop1"].Value.ToString());
   mobj.Dispose();
}

wmi.Dispose();

This of course is all running from a command line app, that's the only
difference.

Any ideas why I get the InvalidOperationException would be grealty
appreciated.
"sam spencer [msft]" - 30 Oct 2004 00:00 GMT
Not being an expert in Instrumentation, I would suspect this is a permissions/rights thing.

Asp.net runs under a really low privelige account. I would suspect that WMI needs admin rights to be able to manage objects. You are probably admin on your own
machine, which is why it works for you in a console app.

Sam
The web platform & tools team
--------------------
>Thread-Topic: Using ManagementClass.GetInstances()
>thread-index: AcS7wvF1u5HgGG5mRi684n3S1H5mJA==
[quoted text clipped - 60 lines]
>Any ideas why I get the InvalidOperationException would be grealty
>appreciated.
SlimFlem - 30 Oct 2004 00:25 GMT
I am local admin on my box at work.  What I ended up doing was to move the
Instrumentation.Publish()  call inside the assembly that actually creates and
loads my WindowsPrincipal object.  This makes better sense anyway because
this doesn't really belong in global.asax.  This works great.

In global.asax, I now simply fire a WMI event to indicate a user was
authenticated on to the site.  I subscribe to this event in my WMI consumer
and then grab the instance of the Instance class and dump the details.  This
is working just like I wanted.

thanks for the reply.

> Not being an expert in Instrumentation, I would suspect this is a permissions/rights thing.
>
[quoted text clipped - 68 lines]
> >Any ideas why I get the InvalidOperationException would be grealty
> >appreciated.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.