By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,136 Members | 1,054 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,136 IT Pros & Developers. It's quick & easy.

Cannot assign Nothing/Anything to dirty COM object?

P: n/a
Hi All,

I have a VB.NET program with a COM object associated with an external
(legacy) application. If the external application is forced closed, my
VB.NET program needs to re-open it.

This works fine if my VB.NET program closes the external application.
However, if the external application is forced closed, I can't clear
or reassign the variable associated with it. Specifically, it throws
"The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)"
and the value never becomes "Nothing".

------------------
if m_objLegacyApp isnot Nothing
try

System.Runtime.InteropServices.Marshal.ReleaseComO bject(m_objLegacyApp)
catch ex as Exception
' Rarely get here.
end try

try
m_objLegacyApp = Nothing
catch ex as Exception
' Get here when external app forced closed. objLegacyApp does
NOT contain nothing.
end try
end if

....

try
m_objLegacyApp = new MyLegacyApp
catch ex as Exception
' Get here when external app forced closed. objLegacyApp still
contains old (invalid) instance.
end try
--------------------

Short of making m_objLegacyApp an array that acts as an expanding
garbage heap, does anyone know how to get around this so that I can
reuse m_objLegacyApp?

Thanks!
Gary Geniesse

Jun 26 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.