在Dot Net中设置可选库引用 [英] Setting Optional Library Reference in Dot Net

查看:64
本文介绍了在Dot Net中设置可选库引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在.Net中为可执行文件设置可选参考库?



我正在开发一个EXE应用程序,后来连接到各种插件(DLL)文件,

现在我的问题是否有可能创建可执行或不运行DLL的可执行文件。



程序应检查某些文件夹中的DLL,如果可用则使用它。



示例案例:

案例1:Chrome,Firefox,Visual Studio - 一些流行的应用程序,能够基于其他插件进行Moding Executable 。类似的系统我需要创建...

案例2:考虑开发使用Excel库导出或导入数据的应用程序,但即使没有安装Excel也应该运行应用程序...



谢谢,

Ashok。 RD。

Is there any way to set up Optional Reference Libraries for Executable in .Net?

I'm Developing a EXE application which is later connected to various Plugins (DLL) files,
Now my question Is it possible to create Executable which run with or without DLL.

Program should check for DLL in some folders, and Use it if available.

Example cases:
Case 1: Chrome, Firefox, Visual Studio - Some popular application which is capable of Moding Executable based on additional plugins. Similar system i need to create...
Case 2: Consider developing application that use Excel library to export or import data, But Application should run even when Excel not installed...

Thanks,
Ashok. RD.

推荐答案

参见 这个 [ ^ ] CP文章。看起来它正是你所需要的。



SA是正确的。请参阅 this [< a href =http://www.drdobbs.com/cpp/implementing-a-plug-in-architecture-in-c/184403942\"target =_ blanktitle =New Window> ^ ]而不是DD文章。



/ ravi
See this[^] CP article. It looks like it's exactly what you need.

SA is correct. Please see this[^] DD article instead.

/ravi


首先,自己大忙一点:不要使用引用的文章在解决方案1中。



您真的需要使用反射并开发插件架构。请查看我过去的答案,其中我解释了所有基本原则:

访问驻留在插件dll中的自定义对象 [ ^ ],

通过它的字符串表示从集合中收集类型 [ ^ ],

动态加载用户控件 [ ^ ]。



或者,您可以使用Microsoft插件框架,MEF:

http://en.wikipedia.org/wiki/Managed_Extensibility_Framework [ ^ ],

http://msdn.microsoft.com/en-us/library/dd460648%28VS.100%29.aspx [ ^ ],

http://mef.codeplex.com/ [ ^ ]。



(WMS Aday建议使用MEF。)



-SA
First of all, do yourself a big favor: don't use the article referenced in Solution 1.

You really need to use reflection and develop a plug-in architecture. Please see my past answers where I explain all the basic principles:
Access a custom object that resides in plug in dll[^],
Gathering types from assemblies by it's string representation[^],
Dynamically Load User Controls[^].

Alternatively, you can use Microsoft plug-in framework, MEF:
http://en.wikipedia.org/wiki/Managed_Extensibility_Framework[^],
http://msdn.microsoft.com/en-us/library/dd460648%28VS.100%29.aspx[^],
http://mef.codeplex.com/[^].

(Credit to Wes Aday who suggested MEF.)

—SA


这篇关于在Dot Net中设置可选库引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆