Hi all, I'm having trouble finding information for what I need. I think it's because I don't really know the nane of what I'm looking for, so keywords are eluding me in my search.

I hope my explanation might give someone a clue who can help or at least tell me what to search.

I want my application to use external third party dll files, from which it will gather information without having to modify my code.

So as an example, I have in my code (which will be compiled as exe) code such as...

namespace NSpace
{
    interface IInterface1
    {
        string name();
        string url();
    }

    class InternalUse : IInterface1
    {
        public string name { get; set; }
        public string url { get; set; }

        string IInterface1.name()
        {
            string name = "site name";
            return name;
        }

        string IInterface1.url()
        {
            string url = @"http://www.somewebsite.com";
            return url;
        }
    }
}

I want end user to be able to create a class in a dll that implements IInterface1, in fact more than one dll and my exe will need to load and use its methods.

So as it stands, my exe will run, and print the name and url returned by the methods in InternalUse class.
My goal is that if my exe finds a dll in specific dir, it should load it, and print the name and url of whatever its ExternalUse class might return, there may be multiple dlls.

So what am I actually talking about, and what is simplest way to go about it?
I would prefer to use no later than .Net 4.

Thanks for reading my noob ramblings.

(edit)
I can, if it makes it easier, enforce the class name that implements IInterface1 in external dll, but not the dll name.

Edited 7 Months Ago by Suzie999

@Suzie999 - you are definitely NOT a noob! In any case, the problem has a couple of components. One is the loading of the DLL in your code - for Linux it is dlopen(), for Windows it is LoadLibrary(). Then there is code to map functions in the shared library to your environment. In most cases, due to name-mangling issues mostly, you can't just use classes in the shared library, but usually only C-style functions. Congratulations, you have just graduated to the next level of software absurdity! :-)

:)

I have just come accross MEF (Managed Extensibility Framework) which is available in .Net 4, in my searchings.

The fewexamples I have found show how to use it all in the same project, which is not what it says it can do on the jar.

So I'll start having a look at that.

I have had a look at MEF, and while it can most certainly do what I want it to, and much more, I think it's overkill for my project, and have learned that all I really need, since I can enforce class and method names, is Assembly.LoadFrom() method.

OK, a class in external dll can not derive from one in my assembly, but I can live with that and easily work around it.

Thanks again.

And yes, that MEF is pretty bloomin' great and something for future projects.

Edited 7 Months Ago by Suzie999

This question has already been answered. Start a new discussion instead.