"COM object that has been separated from its underlying RCW cannot be used."

S

Steve

(I posted this in the ADO.NET NG, but didn't get any responses)

I've started getting this exception since installing vs2005
"COM object that has been separated from its underlying RCW cannot be used."


The code this is causing the exception is:
<code>
try
{
m_command.CommandText = GetAccessSprocString(m_spDeleteProtocol);
m_command.Parameters.Clear();
OleDbParameter param = new OleDbParameter("_protocolID",
protocol.ProtocolID);
m_command.Parameters.Add(param);

// open the connection and execute the update
m_connection.Open();
m_command.ExecuteNonQuery(); // THIS IS THE LINE THAT CAUSES
THE EXCEPTION
}
catch (OleDbException e)
{
m_log.LogError(e.Message, new StackFrame(true));
}
catch (Exception ee)
{
m_log.LogError(ee.Message, new StackFrame(true));
}
finally
{
m_connection.Close();
}
</code>


I honestly can't tell what is doing this. Googling hasn't shed much light.
Anyone know common causes for this exception?
Thanks for any help,
Steve
 
N

Nicholas Paldino [.NET/C# MVP]

Steve,

I would try and create the connection object once in the method itself,
and not store it on the class level as a field.

Hope this helps.
 
S

Steve

Hi Nicholas,

OK, I tried that and I still get the exception. Very weird. I can't really
find much on google either. Any other ideas?



Nicholas Paldino said:
Steve,

I would try and create the connection object once in the method itself,
and not store it on the class level as a field.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Steve said:
(I posted this in the ADO.NET NG, but didn't get any responses)

I've started getting this exception since installing vs2005
"COM object that has been separated from its underlying RCW cannot be
used."


The code this is causing the exception is:
<code>
try
{
m_command.CommandText = GetAccessSprocString(m_spDeleteProtocol);
m_command.Parameters.Clear();
OleDbParameter param = new OleDbParameter("_protocolID",
protocol.ProtocolID);
m_command.Parameters.Add(param);

// open the connection and execute the update
m_connection.Open();
m_command.ExecuteNonQuery(); // THIS IS THE LINE THAT
CAUSES
THE EXCEPTION
}
catch (OleDbException e)
{
m_log.LogError(e.Message, new StackFrame(true));
}
catch (Exception ee)
{
m_log.LogError(ee.Message, new StackFrame(true));
}
finally
{
m_connection.Close();
}
</code>


I honestly can't tell what is doing this. Googling hasn't shed much
light.
Anyone know common causes for this exception?
Thanks for any help,
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top