How can i check if COM Object exists (is registered / is available / can run without problems) before running actions using them?
My application should use other applications COM's (InteropServices) but before i start some action, i would like to check whether i can create COM objects.
It woudnt be a problem if COM's where in same directory, but they're not.
In excample.
I would like to check if sth like this:
CDNBase.ApplicationClass App = new CDNBase.ApplicationClass();
will cause catchable exceptions or something. Than i could create nice MessageBox and block some events till it will be fixed.
Any other solutions like checking if namespace exists or sth, are also ok (i guess 😀 )
I tried to use try / catch, but it fails, google didnt bring me anything special on this, so im asking for your help.
Thanks in advance
Best Answer
Have you tried catching
ComException
:UPDATE: apologies, I wasn't suggesting to suppress the exception. Have updated.
Alternatively, you could search in the registry for the component's
ClassID
:The default value will contain the filesystem full path to the DLL.