c# - Get CPU ID with " ManagementObjectCollection moc = mc.GetInstances(); " doesn't work? -


i trying unique cpu id code :

private string getcpuid()     {         string cpuinfo = string.empty;         managementclass mc = new managementclass("win32_processor");         managementobjectcollection moc = mc.getinstances();         foreach (managementobject mo in moc)         {             if (cpuinfo == "")             {                 //get first cpu's id                 cpuinfo = mo.properties["processorid"].value.tostring();                 break;             }         }         return cpuinfo;     }      private void button_click(object sender, routedeventargs e)     {        messagebox.show(getcpuid());     } 

worked fine me , more 600 other different systems during 1 year selling product. problem must run application administrator no problem. problem started 2days ago when built application first time in visual studio 2013.

before vs 2013 using vs 2012. if run application administrator out of vs 2013 run, on buttonclick event application stops working. tried debug , problem part of code vs 2013 indicates :

managementobjectcollection moc = mc.getinstances(); 

with message:

outofmemoryexception unhandled, unhandled exception of type 'system.outofmemoryexception' occurred in system.management.dll

i searched lot , found similar problems , error none of them mine.

question visual studio 2013 has done application causes not work out of visual studio run (i mean debug folder)? or cause error , how solve this? don't shift vs2012 appreciated .

the problem visual studio installation reinstallation solved. beside did windows 7 updates


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -