mef

How to persist MEF import and export information to disk

守給你的承諾、 提交于 2019-12-18 05:15:12
问题 For my application as described in this question I want to use MEF to scan the available plugin assemblies and then store all the available import and export information in a serialized format (e.g. a set of strings or a memory stream). This is necessary because I need to transfer the import and export information over an AppDomain boundary without loading the plugin assemblies (essentially I want to delay load the plugins). I found some references, for instance this one or this one but none

How do you use ExportFactory<T>

余生长醉 提交于 2019-12-18 05:14:53
问题 I am new to MEF and experimenting with ExportFactory. Can I use ExportFactory to create a list based on user insertion of objects? A sample would be something similar to what is shown below. I am probably not understanding the use of ExportFactory because during runtime I get an error shown below during composition. 1) No valid exports were found that match the constraint '((exportDefinition.ContractName == "System.ComponentModel.Composition.ExportFactory(CommonLibrary.IFoo)") AndAlso

Facing error during catalog refresh, the new dll is not used

时光总嘲笑我的痴心妄想 提交于 2019-12-18 02:54:14
问题 I am trying to create a POC with mef where i have the requirement to load dll dynamically in an all ready running project , for this i have created one console application project and a class Library project . the code for console application project is as follows- namespace MefProjectExtension { class Program { DirectoryCatalog catalog = new DirectoryCatalog(@"D:\MefDll", "*.dll"); [Import("Method1", AllowDefault = true, AllowRecomposition = true)] public Func<string> method1; static void

Is MEF a replacement for System.Addin? [duplicate]

会有一股神秘感。 提交于 2019-12-17 19:48:29
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Choosing between MEF and MAF (System.AddIn) Is the Managed Extensibility Framework a replacement for System.Addin? Or are they complementary? 回答1: It is touched in the MSDN Forums here: Comparison to the AddIn libraries? And also by Krzysztof Cwalina in his blog on the release of MEF: Managed Extensibility Framework Summary : they live side by side. 回答2: Short answer no it is not. System.Addin allows you to

Looking for a practical approach to sandboxing .NET plugins

≯℡__Kan透↙ 提交于 2019-12-17 08:01:22
问题 I am looking for a simple and secure way to access plugins from a .NET application. Although I imagine that this is a very common requirement, I am struggling to find anything that meets all my needs: The host application will discover and load its plugin assemblies at runtime Plugins will be created by unknown 3rd parties, so they must be sandboxed to prevent them from executing malicious code A common interop assembly will contain types that are referenced by both the host and its plugins

Thread-Safe lazy instantiating using MEF

血红的双手。 提交于 2019-12-13 13:18:32
问题 // Member Variable private static readonly object _syncLock = new object(); // Now inside a static method foreach (var lazyObject in plugins) { if ((string)lazyObject.Metadata["key"] = "something") { lock (_syncLock) { // It seems the `IsValueCreated` is not up-to-date if (!lazyObject.IsValueCreated) lazyObject.value.DoSomething(); } return lazyObject.value; } } Here I need synchronized access per loop. There are many threads iterating this loop and based on the key they are looking for, a

MEF 'The export is not assignable to type' error

戏子无情 提交于 2019-12-13 13:04:42
问题 I have just started using MEF and have hit on an early problem. I have an interface called DataService: namespace DataAccess { interface IDataService { string Name { get; } string Description { get;} List<String> GetPeople(); } } There are 2 implementations of this interface, one for SQL Server and one for Oracle. Below is the Oracle implementation, SQL Server implementation is exactly the same. namespace DataAccess { [Export(typeof(IDataService))] [ExportMetadata("Name","Oracle")]

Get the current filename from a Visual Studio text adornment extension

血红的双手。 提交于 2019-12-13 12:06:57
问题 I'm new to VS extension development. I'm currently working with the text adornment sample in VS 2015 and have been able to get coloured boxes showing correctly. Now I want to extend the sample so the adornment only appears on certain file names. Googling has said I can use ITextDocumentFactoryService.TryGetTextDocument interface with the IWpfTextView.TextBuffer property to get a filename. This sounds great. But I can't seem to actually get the interface. In my class I have: [Import] public

Ninject and Custom Controller Factory

此生再无相见时 提交于 2019-12-13 04:27:51
问题 I'm using MEF with ASP.NET MVC as demonstrated at http://blog.maartenballiauw.be/post/2009/06/17/Revised-ASPNET-MVC-and-the-Managed-Extensibility-Framework-(MEF).aspx. When I try to use Ninject, it seems that nothing gets injected. I did some debugging, and when I reverted to the original controller factory the injection worked. What needs to be changed, or what does Ninject need in terms of controller factories for it to work? 回答1: Check out Nate Kohari's Ninject.Web.MVC project on GitHub.

questions about using MEF in a WCF service

核能气质少年 提交于 2019-12-13 01:07:22
问题 I'm just starting to play with MEF and have a couple questions. 1) I wrote a WCF service that takes in some xml and passes the xml off to a parser. The parsers are composed using MEF. (metadata in the xml lets me determine which parser to use). I can add a new parser, and support new XML, by just dropping the dll in a directory. That part all works. But, WCF services can be instantiated multiple times, I want my parser catalog to be static, that is, if multiple instances of my service are