validation - C# interop - validate object exists -


I would like to use the COM object in my application.
How can I ensure that the machine is registered in the object?

Try {Foo.Bar COM_oObject = new Foo.Bar ()

The only solution I found (also) was to use an attempt-holding block around the initialization:

  try {Foo.Bar COM_oObject = new Foo.Bar (); } Hold (exception EE) {// something went wrong during the init of COM object}  

Can I do it any other way?
I am feeling hopeless in dealing with an error and by reporting it, I will know that I will fail and start to avoid it from start.

You are using the exception to dealing with the right way: For how do you know how to recover

In this case, there is no problem in using the try-hold, but you can at least catch it specially: ComException.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -