locked
Problem in fetching performance counter data of "ASP.NET" and "ASP.NET Applications". RRS feed

  • General discussion

  •  

    Hi All,

      I am trying to fetch data from performance counter of "ASP.NET" and "ASP.NET Applications". This is a C++ based application. I have put sample code part of this application.  This application is based on a sample provided on microsoft site.

     

    IWbemLocator *pLoc;

    IWbemServices *pSvc;

    IEnumWbemClassObject *pEnumeratorASPNET;

     

    //Step 1 - Initailize COM
    //Step 2 - Set security related parameter for COM authentication
    //Step 3 - Create Instance of IWebmLocator
    //Step 4 - Connect to WMI Namespace
    //Step 5 - Connect to Proxy
    //Step 6 - Run required queries
      hr = pSvc->ExecQuery(
       bstr_t("WQL"),
       bstr_t("SELECT * FROM ASP.NET"),
       WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
       NULL,
       &pEnumeratorASPNET);

     

      if (FAILED(hr))
      {
       pSvc->Release();
       pLoc->Release();
       CoUninitialize();
       return;
      }

    My problem is i am not getting data for the above two generic perfromance counters if i try to access it through code.  But it shows data in perfmon. If try to access version specfic performance counter i can access it.

     

    If any quick help would be appreciated

     

    Thanks in advance,

    Gangaprasad

    Friday, November 2, 2007 11:30 AM

All replies

  • Is your code running in full trust?
    1.  
    Friday, November 2, 2007 5:27 PM
  • Hi gp_dotnet_guy,

    We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.  

    Thank you!

    Monday, November 5, 2007 2:55 AM
  • Hi Inbar Gazit

       Sorry for late reply because i was out for office for couple of days. Anyways  to answer your question i am putting here code details of step 1 to step 5 which were not there in my previous post.

     

    HRESULT hr;

    IWbemLocator *pLoc;

    IWbemServices *pSvc;

     

    //Step 1 - Initailize COM

    hr = CoInitializeEx(0, COINIT_MULTITHREADED);

    if (FAILED(hr))

    {

    return;

    }

     

    //Step 2 - Set security related parameter for COM authentication

    hr = CoInitializeSecurity(

    NULL,

    -1, // COM authentication

    NULL, // Authentication services

    NULL, // Reserved

    RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication

    RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation

    NULL, // Authentication info

    EOAC_NONE, // Additional capabilities

    NULL // Reserved

    );

     

    if (FAILED(hr))

    {

    CoUninitialize();

    return;

    }

     

    //Step 3 - Create Instance of IWebmLocator

    hr = CoCreateInstance(CLSID_WbemLocator,0,CLSCTX_INPROC_SERVER,IID_IWbemLocator, (LPVOID *) &pLoc);

    if (FAILED(hr))

    {

    CoUninitialize();

    return;

    }

     

    //Step 4 - Connect to WMI Namespace

    hr = pLoc->ConnectServer(

    _bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace

    NULL, // User name. NULL = current user

    NULL, // User password. NULL = current

    0, // Locale. NULL indicates current

    WBEM_FLAG_CONNECT_USE_MAX_WAIT, // Security flags.

    0, // Authority (e.g. Kerberos)

    0, // Context object

    &pSvc // pointer to IWbemServices proxy

    );

     

    if (FAILED(hr))

    {

    pLoc->Release();

    CoUninitialize();

    return;

    }

     

    //Step 5 - Connect to Proxy

    hr = CoSetProxyBlanket(

    pSvc, // Indicates the proxy to set

    RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx

    RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx

    NULL, // Server principal name

    RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx

    RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx

    NULL, // client identity

    EOAC_NONE // proxy capabilities

    );

     

    if (FAILED(hr))

    {

    pSvc->Release();

    pLoc->Release();

    CoUninitialize();

    return;

    }

     

    //Step 6 - Rest of code goes here

     

    Here i am using default authentication and impersonation. Using this same credentials i am able to get data of perfmon object "ASP.NET v1.1.4322", "ASP.NET App v1.1.4322" etc. Only it is not working for generic perfmon object "ASP.NET", "ASP.NET Applications".  If you need more information please feel free to ask.
    Monday, November 12, 2007 10:13 AM