[C#]条件dll引用 [英] [C#] Conditional dll reference
本文介绍了[C#]条件dll引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我有外部库(不是DLL而是整个项目)。该项目使用Office Interop。但是,在没有安装Office的计算机上也会打开软件。在这种情况下,我只想灰色excel导出功能。我怎么能这样做?
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?
推荐答案
.NET程序集是根据需要由CRL引擎加载的,所以没有太多的东西......但是有一个 AssemblyResolve [ ^ ]应用程序域事件,该事件可以帮助您处理缺失的参考...
请阅读这些:
https://msdn.microsoft.com/en-us/library/dd153782(v = vs.110)的.aspx [< a href =https://msdn.microsoft.com/en-us/library/dd153782(v=vs.110).aspx\"target =_ blanktitle =New Window> ^ ]
https://msdn.microsoft.com/ en-us / library / ff527268(v = vs.110).aspx [ ^ ]
.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[^]
即使安装了Office,也不保证互操作组件存在。您应该将Microsoft.Office.Interop.Excel包含在程序安装程序的一部分中。阅读此处 [ ^ ]了解有关互操作的更多详细信息。程序运行时,请检查注册表以确定是否已安装Office。阅读此 [ ^ ]和这个 [< a href =http://stackoverflow.com/questions/13979296/check-if-office-is-installed-in-64-bit-win-os-using-registrytarget =_ blanktitle =新窗口> ^ ]有关检查注册表的更多信息。
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.
这篇关于[C#]条件dll引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文