I
Ian Frawley
COM object that has been separated from its underlying RCW can not be used.
It is an exception that is being generated by a windows service that I have
developed. I have only seen 2 entries on MSDN for this and to be honest both
of them look irrelevant to what I have developed as they point more at
ASP.NET.
To make matters worse this only happens on our live server, which makes it
very difficult to replicate on our test bed.
As a bit of background it all revolves around a WMI query and is generated
by the following code:
try
{
query = new System.Management.ObjectQuery(WMIQuery);
ManagementObjectSearcher search = new ManagementObjectSearcher();
search.Query = query;
search.Scope = ms;
instance = 0;
ManagementObjectCollection queryCollection = search.Get();
instances = queryCollection.Count;
try
{
foreach ( ManagementObject mo in queryCollection) //////////////// THIS
LINE GENERATES THE EXCEPTION
{
instance++;
foreach(int MetricID in metricstemp._Metrics.Keys)
{
Metric mettemp = (Metric)metricstemp._Metrics[MetricID];
if(mo[mettemp.Name] != null)
{
try
{
logmessage.LogMessage(Log.LogType.LogInformation,mettemp.ID + " " +
mo[mettemp.Name].ToString() + " " + this._DataCollector.ToString() + " " +
mettemp.Name.ToString() + " " + instance.ToString() + " " +
instances.ToString());
metricstemp.SaveMetric(mettemp.ID, mo[mettemp.Name].ToString(),
this._DataCollector, mettemp.Name.ToString(), instance, instances);
}
catch(Exception SaveMetricException)
{
logmessage.LogMessage(Log.LogType.LogCritical,SaveMetricException.Message);
throw SaveMetricException;
}
}
}
}
}
catch(Exception OHMyGOD)
{
logmessage.LogMessage(Log.LogType.LogCritical,"Massive DEBUG - " +
OHMyGOD.Message);
}
}
catch(ManagementException ex)
{
if (ex.Message.ToString() == "Invalid class ")
logmessage.LogMessage(Log.LogType.LogCritical,"Unable to collect metrics
because the class '" + classRow.Name + "' could not be found on server '" +
_DataCollector.NetworkName + "' (" + _DataCollector.IPAddress + ")");
else
logmessage.LogMessage(Log.LogType.LogCritical,"Unable to collect metrics
for the class '" + classRow.Name + "' because " + ex.Message);
throw ex;
}
Cheers
Ian
--
"Life should NOT be a journey to the grave
with the intention of arriving safely in an
attractive and well preserved body,
but rather to skid in sideways,
chocolate in one hand, beer in the other,
body thoroughly used up,
totally worn out and screaming
WOO HOO what a ride!"
It is an exception that is being generated by a windows service that I have
developed. I have only seen 2 entries on MSDN for this and to be honest both
of them look irrelevant to what I have developed as they point more at
ASP.NET.
To make matters worse this only happens on our live server, which makes it
very difficult to replicate on our test bed.
As a bit of background it all revolves around a WMI query and is generated
by the following code:
try
{
query = new System.Management.ObjectQuery(WMIQuery);
ManagementObjectSearcher search = new ManagementObjectSearcher();
search.Query = query;
search.Scope = ms;
instance = 0;
ManagementObjectCollection queryCollection = search.Get();
instances = queryCollection.Count;
try
{
foreach ( ManagementObject mo in queryCollection) //////////////// THIS
LINE GENERATES THE EXCEPTION
{
instance++;
foreach(int MetricID in metricstemp._Metrics.Keys)
{
Metric mettemp = (Metric)metricstemp._Metrics[MetricID];
if(mo[mettemp.Name] != null)
{
try
{
logmessage.LogMessage(Log.LogType.LogInformation,mettemp.ID + " " +
mo[mettemp.Name].ToString() + " " + this._DataCollector.ToString() + " " +
mettemp.Name.ToString() + " " + instance.ToString() + " " +
instances.ToString());
metricstemp.SaveMetric(mettemp.ID, mo[mettemp.Name].ToString(),
this._DataCollector, mettemp.Name.ToString(), instance, instances);
}
catch(Exception SaveMetricException)
{
logmessage.LogMessage(Log.LogType.LogCritical,SaveMetricException.Message);
throw SaveMetricException;
}
}
}
}
}
catch(Exception OHMyGOD)
{
logmessage.LogMessage(Log.LogType.LogCritical,"Massive DEBUG - " +
OHMyGOD.Message);
}
}
catch(ManagementException ex)
{
if (ex.Message.ToString() == "Invalid class ")
logmessage.LogMessage(Log.LogType.LogCritical,"Unable to collect metrics
because the class '" + classRow.Name + "' could not be found on server '" +
_DataCollector.NetworkName + "' (" + _DataCollector.IPAddress + ")");
else
logmessage.LogMessage(Log.LogType.LogCritical,"Unable to collect metrics
for the class '" + classRow.Name + "' because " + ex.Message);
throw ex;
}
Cheers
Ian
--
"Life should NOT be a journey to the grave
with the intention of arriving safely in an
attractive and well preserved body,
but rather to skid in sideways,
chocolate in one hand, beer in the other,
body thoroughly used up,
totally worn out and screaming
WOO HOO what a ride!"