0

I have an app that I am developing. It is compiled with the ANYCPU profile so i will be able to have it run on both 32 and 64 bit machimes.

I am attempting to detect various pieces of system information using the ManagementClass and ManagementObjectClass

Whenever I try to access this library I get and exception.

My code snippet looks like:

string result = "";
        System.Management.ManagementClass mc =
    new System.Management.ManagementClass(wmiClass);
        System.Management.ManagementObjectCollection moc = mc.GetInstances();

The exception I get is

Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

I have read the numerous articles stating that to make this work change the configuration to x86 and yes that works in standalone test. This however is part of a larger application with dependencies and I rather not make it exclusively 32bit.

I have a hard time believing that this .Net library will only work on 32 bit apps. Its there some way of doing what I am trying to do?

A work around I am attempting is to spawn a process of a 32bit wrapped app with the functionality I need and dumping the results into a database which I will read in the 64 bit app. Thoughts?

Jeff
  • 2,061
  • 4
  • 27
  • 45

0 Answers0