开发者

WMI Providers with ASP.NET

I'm writing a small ASP.NET page to detect and display information for installed SSRS instances on the local server.

I found the following tool really useful from Microsoft... WMI Code Creator

The code it generates works great when run from the command line. However when trying to execute the same code within my ASP.NET page I get a...

"Unhandled Execution Error" Exception Details: System.Runtime.Inter开发者_开发百科opServices.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"]));
    }

My guess is there is some sort of permissions issue via IIS, however I'd be grateful for a definitive answer. I thought it might be a problem with all WMI providers through ASP.NET, however the following code works fine in 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 as to what exactly is going on behind the scenes and maybe why I'm getting the above exception would be very welcome.


add Network Service account into the launch conditions for DCOM using dcomcnfg.

Type dcomcnfg in cmd

go to Component Services ->My Computer ->Com Security ->Lauch and Activate Permissions ->Edit Default ->Add...

Now add Network Service and allow all permisions to it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜