Link to home
Start Free TrialLog in
Avatar of michellechan57
michellechan57

asked on

C# Excel Automation Library Exist?

Is there anyway to verify if required version of Excel Automation Library exist in C#?
I would like to check for its existence before instantiate an instance of Excel.Application to prevent an error message that say Excel does not exist.
ASKER CERTIFIED SOLUTION
Avatar of TheAvenger
TheAvenger
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mitchellm44
mitchellm44

You can try reading the Registry and see if you can find that ID in the registry.
Then you will know if it exists or not.

There are some configurations that may deny registry access - however you should give it a try.
Avatar of michellechan57

ASKER

I have tried to catch the exception but a dialog box pop up with message "... :Retrieving the COM class factory for component ... failed due to the following error: 80040154 ...".
I have also tried reading the registry but not all client PC has the necessary rights to access it.

I need a better (more graceful) method to disallow user to use the Excel Automation Library if it is not present.
Did you debug the application? On which line does it fail?
OK, the error message was from the exception caught.
I missed the point. Answer accepted. Thanks.