Advertisement

11.22.2005 at 03:00AM PST, ID: 21639326
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

C++/CLI Best way to approach plugin programming

Asked by Moo-Juice in Microsoft Visual C++.Net, Plug Ins

Tags: , , ,

Hi All,

I'm in the process of working on an application under Visual Studio 2005, C++/CLI.  In the past, I have coded many apps under C++ and when I've wanted to allow "plugins" to be written by 3rd parties or myself to enhance a product after an initial release, I tended to provide a DLLs, and dynamically load "plugin" DLLs at runtime with class factories etceteras facilitating the process.

Now, I'm moving on to the new C++/CLI language, I want to take advantage of the way .NET works, but am not sure of the "good" way to go about it, hence this question!

At first, things seem pretty simple.  Let's say I have my product, and in a DLL is something like:

namespace MyNamespace
{
    public ref class MyPlugin abstract
    {
       // all plugin members, methods, virtuals etc
    };
};

Then, easily enough, someone with Visual studio can create a reference to this DLL, and go:

namespace 3rdPartyPlugin
{
    public ref class 3rdPartyClass : MyNameSpace::MyPlugin
    {
    // 3rd party plugin implementation
    };
};


Now, when the app loads, I could have an XML file which described these things:

<approot>
    <plugins>
        <plugin name="3rdpartyPlugin" lib="3rdparty" class="3rdPartyPlugin.3rdPartyClass" />
    </plugins>
</approot>


During loading, my application can instantiate this plugin (assuming the .dll is in the right location!):

Object^ pPlugin(AppDomain::CurrentDomain->CreateInstanceAndUnwrap(strLib, strClass));
MyPlugin^ pInstance(dynamic_cast<MyPlugin^>(pPlugin));
if(!pInstance) // cast failed, not a MyPlugin?
{
};


Is this the best way to go about it?  How would I add my product .DLL to a GAC so that rather than  browsing for my DLL, the developer selects the namespace alongside all the Microsoft ones?  Is there an easy way for my application to locate DLLs that are plugins?


Sorry for so many questions.  I have it working, but am not convinced I've done it in the best way.



Thanks in advance.Start Free Trial
 
Loading Advertisement...
 
[+][-]11.22.2005 at 06:00AM PST, ID: 15341674

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C++.Net, Plug Ins
Tags: appdomain, cli, dynamic_cast, plugin
Sign Up Now!
Solution Provided By: lakshman_ce
Participating Experts: 1
Solution Grade: A
 
 
[+][-]01.26.2006 at 02:08AM PST, ID: 15793753

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]01.30.2006 at 12:42PM PST, ID: 15827511

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32