locked
Linking DLL with external resource dependency based on MEF RRS feed

  • Question

  • I read both .net MEF (Managed Extensibility Framework) and MAF (System.AddIn) and I got confused by their online reviews.

    While MEF seems newer and more attractive than MAF. I can't understand how we can link an extension with .NET application using MEF. For example, in MAF, I can develop my entire extension logic (AddIn) which involves:

    • main dll, say X.dll
    • all the dlls referenced by X.dll
    • external resources that X.dll needs such as a database, some textfiles ... etc

    then the Host can simply call a method inside X.dll and waits for the result.

    On the other hand, MEF requires that all DLLs to be located in the same folder, say "Plugins", hence X.dll must be in "Plugins" in order to be discovered and linked, so my question how we can embed all the resources that X.dll requires to complete an incoming request from the host?

    My real question is: if a team is to design a host application that its processing capabilities can be extended by relying on extensions developed by other teams or simply downloaded and installed from the internet, Is MEF an effective technology in such project? or should the team stick with MAF ?

    P.S: My question is not about which one is better in terms of security ... etc. Instead I am more interested in finding out if MEF allows hooking up assemblies that require their own external resources to be available around the assembly, such as a spell checker extension which requires some corpus of text and a heuristics database, these two resources are required by the extension but not required by the host itself

    Furthermore, in my former example if X.dll requires Y.dll to run, I cann't simply put both dlls in the "Plugins" folder, because y.dll is not an extension.

    Tuesday, September 27, 2016 9:37 PM

Answers

  • Hi alrehamy,

    Thank you for posting here.

    >>Is MEF an effective technology in such project?

    1. When a part is created, the MEF composition engine satisfies its imports with what is available from other parts.

    2. There is no need to carefully specify when and how extensions should be loaded.

    3. In addition to its provided exports, a part can specify its imports, which will be filled by other parts.

    4.Because the MEF model requires no hard dependency on a particular application assembly, it allows extensions to be reused from application to application.

    5. Extension components themselves are automatically extensible.

    >>or should the team stick with MAF ?

    MEF is an integral part of the .NET Framework 4, and is available wherever the .NET Framework is used. You can use MEF in your client applications, whether they use Windows Forms, WPF, or any other technology, or in server applications that use ASP.NET.

    Previous versions of the .NET Framework introduced the Managed Add-in Framework (MAF), designed to allow applications to isolate and manage extensions. The focus of MAF is slightly higher-level than MEF, concentrating on extension isolation and assembly loading and unloading, while MEF's focus is on discoverability, extensibility, and portability. The two frameworks interoperate smoothly, and a single application can take advantage of both.

    I hope this would be helpful to you.

    If you have something else, please feel free to contact us.

    Best Regards,

    Wendy


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by DotNet Wang Monday, October 10, 2016 6:16 AM
    • Marked as answer by DotNet Wang Monday, October 10, 2016 6:26 AM
    Wednesday, September 28, 2016 12:31 PM