[C#]条件dll引用

[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 [ ^ ]

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。阅读 [ ^ ]和这个 [ ^ ]有关检查注册表的更多信息。
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.