My code tries to detect all the instances of sql server installed locally or in the network. This project is done with Visual studio 2015 community (Update 1) and under Windows 10 OS. i use this code:
ManagementScope ms = new ManagementScope(correctNamespace);
ManagementObjectSearcher getSqlEngine = new ManagementObjectSearcher(ms, query);
//ManagementObjectSearcher getSqlEngine = new ManagementObjectSearcher(correctNamespace, query);
if (getSqlEngine.Get().Count == 0)
{
return null;
}
The correctNamespace is given by a routine to calculate the correct namespace for wmi. And the returned string is something like:
"root\\Microsoft\\sqlserver\\ComputerManagement12";
when i run that code on Visual Studio, gives me the system.management.Exception "System.Management.dll cannot be load"
i tried it with different frameworks (4.0 and 4.5.2) and i get always the same exception.
Scenario: I had to Re-apply the famous major Update for windows 10 .. 1511, cause i got problems with windows store.
and i deleted sql server 2012 who was there, and now i run sql server 2014 express with advance....
i don't have problems to open and manipulate data using SSMS.
is there something broken on Visual Studio (I am trying to Repair it now). or it is in the OS?. i tried to re-register System.Management.Instrumentation.dll using regsvr32 but i get the error "Cant not found the entry point.."
PowerShell works fine.... SO i don't know where to watch more. No repair tool for netframework on Windows 10.. or googling it gives no results.... so Please any one can help?