I am writing a small ASP.NET page to discover and display information for installed SSRS instances on a local server.
I found the following tool really useful for Microsoft ... WMI code creator
The generated code works great when run from the command line. However, when I try to execute the same code on my ASP.NET page, I get ...
"Runtime Error" Exception Details: System.Runtime.InteropServices.COMException
This is the code ...
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\Microsoft\\SqlServer\\ReportServer\\[INSTANCE_HERE]\\v10\\Admin", "SELECT * FROM MSReportServer_ConfigurationSetting"); foreach (ManagementObject queryObj in searcher.Get()) { Response.Write(string.Format("InstanceName: {0}", queryObj["InstanceName"])); }
I assume that there are some problems with permissions through IIS, however I would be grateful for the final answer. I thought this could be a problem with all WMI providers through ASP.NET, however the following code works fine on the page ...
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_OperatingSystem"); foreach (ManagementObject queryObj in searcher.Get()) { Response.Write(string.Format("Name: {0}", queryObj["Name"])); }
Any help on what exactly is going on behind the scenes, and perhaps why I get the above exception, would be very welcome.
source share