Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Hello

I have external library (not DLL but whole project). This project uses Office Interop. But software will be opened also on computers without Office installed. In this case I want just gray out excel export function. How can I do this?
Posted

.NET assemblies are loaded by the CRL engine upon demand, so not much to do there...However there is an AssemblyResolve[^] event of the application domain, that event may help you to handle the missing reference...
Please also read these:
https://msdn.microsoft.com/en-us/library/dd153782(v=vs.110).aspx[^]
https://msdn.microsoft.com/en-us/library/ff527268(v=vs.110).aspx[^]
 
Share this answer
 
The interop components are not guaranteed to be present, even if Office is installed. You should include Microsoft.Office.Interop.Excel as part of your program’s installer. Read here[^] for more details on interops. When your program is running check the registry to determine if Office is installed. Read this [^] and this [^]for more information on checking the registry.
 
Share this answer
 
v3
Comments
Marcin1199 26-Jan-15 15:54pm    
Yes but in publishing settings I set to include all dll to project but even with that on some computers with Office installed I had message that Office is missing or Core is missing.
BillW33 27-Jan-15 10:29am    
I edited my answer to make it more clear. As I stated, even if you have included the interop in your installer you still need to have your program check during runtime to determine if Office is installed. Read the links in the answer to see how to check for the presence of Office.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900