[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.programming

COMSvcsLib COM+ monitor in .NET 4

lachlann

3/22/2016 7:21:00 PM

I am trying to create a COM+ monitor webservice in .NET 4, i can see that the function i need to use is:
IGetAppTrackerData::GetComponentDetails

https://msdn.microsoft.com/en-us/library/windows/deskto...(v=vs.85).aspx

however the .net interop only exposes RemoteGetComponentDetails

When i call this function i keep getting ArgumentOutOfRange exception but i can't find any clues as to what argument is out of he range, i've double and triple check my guid's, process id and flags and they all appear correct.

i'm trying to catch the scenario when our application has component call times over X seconds.






var Details = new AppInstanceDetail(AppInstProperties);

if (_AppComponentsDict.ContainsKey(AppInstProperties.ApplicationID))
{
var CompList = _AppComponentsDict[AppInstProperties.ApplicationID];


for (int i = 0; i < CompList.Count; i++)
{
Guid CLSID = CompList[i];
Guid empty = Guid.Empty;
COMSVCSLib.ComponentSummary Summary = new COMSVCSLib.ComponentSummary();
COMSVCSLib.ComponentStatistics Statistics = new COMSVCSLib.ComponentStatistics();
COMSVCSLib.ComponentHangMonitorInfo HangInfo = new COMSVCSLib.ComponentHangMonitorInfo();


try
{

Guid AppID = _ComponentPropertiesDict[CompList[i]].ApplicationID;

//https://msdn.microsoft.com/en-us/library/windows/deskto...(v=vs.85).aspx
getAppData.RemoteGetComponentDetails(ref empty,
(uint)AppInstProperties.ProcessID,
ref AppID,
(uint)GetAppTrackerDataFlags.GATD_INCLUDE_CLASS_NAME,
ref Summary,
ref Statistics,
ref HangInfo);
} catch (ArgumentException ex)
{
throw new ArgumentException(string.Format("Unable to get statistics for {0}::{1}, Original Error: {2}",_AppPropertiesDict[AppInstProperties.ApplicationID].Name,_ComponentPropertiesDict[CompList[i]].ProgID,ex.Message),ex);
}
Details.Components.Add(new ComponentInstanceDetail(
_ComponentPropertiesDict[CLSID],
Summary, HangInfo, Statistics
));

}
}
return Details;
}//private AppInstanceDetail GetTrackerDetails(AppInstanceProperties AppInstProperties)






The _ComponentPropertiesDict is a dictionary with the key being the CLSID from the component (populated from ICatalogObject from the Components collection) and the value is a class that captures the properties of the component.

public static ComponentProperties GetComponentProperties(this COMAdmin.ICatalogObject comp)
{
var prop = new ComponentProperties();


prop.CLSID = new Guid(comp.get_Value("CLSID").ToString());
prop.ApplicationID = new Guid(comp.get_Value("ApplicationID").ToString());

prop.ComponentTransactionTimeout = (int)comp.get_Value("ComponentTransactionTimeout");
prop.ComponentTransactionTimeoutEnabled = (bool)comp.get_Value("ComponentTransactionTimeoutEnabled");
prop.EventTrackingEnabled = (bool)comp.get_Value("EventTrackingEnabled");
prop.IsEnabled = (bool)comp.get_Value("IsEnabled");
prop.MaxPoolSize = (int)comp.get_Value("MaxPoolSize");
prop.MinPoolSize = (int)comp.get_Value("MinPoolSize");
prop.ObjectPoolingEnabled = (bool)comp.get_Value("ObjectPoolingEnabled");
prop.Transaction = (COMAdminTransaction)comp.get_Value("Transaction");
prop.TxIsolationLevel = (COMAdminTxIsolationLevel)comp.get_Value("TxIsolationLevel");



prop.Description = comp.get_Value("Description").ToString();
prop.DLL = comp.get_Value("DLL").ToString();
prop.ProgID = comp.get_Value("ProgID").ToString();

prop.Name = comp.Name.ToString();

return prop;
}









The AppInstProperties variable is a class that captures the output of the ICatalogObject for the ApplicationIstances collection:


public static AppInstanceProperties GetAppInstanceProperties(this COMAdmin.ICatalogObject appInst)
{
var prop = new AppInstanceProperties();
prop.InstanceID = new Guid(appInst.get_Value("InstanceID").ToString());
prop.ProcessID = (int)appInst.get_Value("ProcessID");
prop.PartitionID = new Guid(appInst.get_Value("PartitionID").ToString());
prop.IsPaused = (bool) appInst.get_Value("IsPaused");
prop.HasRecycled = (bool) appInst.get_Value("HasRecycled");
prop.ApplicationID = new Guid(appInst.get_Value("Application").ToString());

return prop;
}