Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Visual-Studio VB>NET
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.
Posted 23-Jul-14 4:46am
Comments
Wes Aday at 23-Jul-14 10:49am
   
Not sure exactly what the issue is. Sounds like you should look into using MEF or similar.
Sergey Alexandrovich Kryukov at 23-Jul-14 21:04pm
   
I credited this idea in my answer.
 
Unfortunately, OP accepted a very counter-productive solution referencing a really bad article.
I provide the advise which really works, please see my answer. In fact, my approach is simpler than MEF, so I prefer using it, at least in most cases which are simple enough.
 
—SA
RyanDev at 23-Jul-14 10:50am
   
Reflection is one way to go.
Sergey Alexandrovich Kryukov at 23-Jul-14 21:02pm
   
You are right. Unfortunately, OP accepted a very counter-productive solution referencing a really bad article.
I provide the advise which really works, please see my answer.
—SA
Sergey Alexandrovich Kryukov at 23-Jul-14 20:43pm
   
Why?
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

See this[^] CP article. It looks like it's exactly what you need.
 
SA is correct. Please see this[^] DD article instead.
 
/ravi
  Permalink  
v2
Comments
Ashok19r91d at 23-Jul-14 11:05am
   
+5 Something looks like my need...
Ravi Bhavnani at 23-Jul-14 11:09am
   
If you find it useful, please accept and rate the solution. This will make it easier for others to find it. Thanks.
 
/ravi
Ashok19r91d at 23-Jul-14 11:18am
   
already marked...
Sergey Alexandrovich Kryukov at 23-Jul-14 20:53pm
   
Did you try to use this library yourself? The code I can see is full with nonsense.
 
First of all, the author takes some substring of the DLL file name and loads it with Assembly.Load. This is not how it works. This method takes long assembly name, which is not a file name. For file name, one would need to use Assembly.LoadFrom. The code does not check up if some classes really implement some plug-in interface. There is no a reasonable way of identification of the class taken from the library. It should be the type implementing some interface known by the host. And so on... In other words, this is not a working solution.
 
You see, to advise some article, you need to be sure that what you advise makes sense. Such answers can easily mislead people and frustrate them a lot.
 
—SA
Ravi Bhavnani at 24-Jul-14 8:16am
   
Hi Sergey, no I didn't run the sample project before recommending it as a possible solution. Thanks for the heads up.
 
/ravi
Ravi Bhavnani at 24-Jul-14 8:23am
   
I've updated my solution with a link to a correct implementation.
 
/ravi
Sergey Alexandrovich Kryukov at 24-Jul-14 12:48pm
   
Much better. I appreciate that. My 5.
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
v2

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



Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 24 Jul 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100