mef

MEF Dependencies and versioning

泪湿孤枕 提交于 2019-12-03 07:30:43
问题 I have a system that uses MEF to load parts. Each of these parts rely on a core library. When I build the project, I add a version number to the .dll files like this: part1-1.0.0.0.dll part2-1.0.0.0.dll Also, there is an application that performs MEF composition. It also uses the core library. I've found that I can just deploy the "part" dlls, and composition works fine because the application has already loaded the core library that the parts rely on. So my file system looks something like

What should I use in Prism- MEF or Unity?

依然范特西╮ 提交于 2019-12-03 07:17:55
Found several good(related) questions here and here but all are nearly a year old. I will like to know in the current context of Prism development what is better or at least scenario where each is better. They are two approaches to solving some-what overlapping scenarios. Unity shines when you are developing a modular application where users will be using a subset of the modules and modules are self-contained. MEF shines when you have a lot of 3rd party developers creating plug-ins for your application - or several development teams publishing plugins. We started out with Prism for core

Prism v4: Unity or MEF?

与世无争的帅哥 提交于 2019-12-03 05:36:14
问题 I downloaded Prism v4 and ran the installer. I went into the directory and ran the two following batch files: Desktop only - Open Modularity With Mef QuickStart.bat Desktop only - Open Modularity With Unity QuickStart.bat When I compile these applications, I don't see any real difference. I've searched for MEF vs Unity and I've found some pros/cons, but nothing that specifically states whether one is "better" (and I know that is subjective) with use in Prism. I guess perhaps if I list my

export generics in MEF

假装没事ソ 提交于 2019-12-03 05:35:26
I want to export a generic class to a generic interface via MEF. My objects are: public interface IService<T> { } [Export(typeof(IService<T>))] // error!!!!!! public class Service<T> { } public class Client<T> { [Import] private IService<T> _service; } But when I try to export IService<T> , I get this error: Attribute argument cannot use type parameters Can anybody guide me to do this please? Try [Export(typeof(IService<>))] To get a generic type definition from the typeof operator, you omit type arguments. For types with more than one type parameter, use commas to indicate the "arity" of the

Disadvantages of Lazy<T>?

允我心安 提交于 2019-12-03 04:53:46
问题 I recently started using Lazy throughout my application, and I was wondering if there are any obvious negative aspects that I need to take into account when using Lazy<T> ? I am trying to utilize Lazy<T> as often as I deem it appropriate, primarily to help reduce the memory footprint of our loaded, but inactive plugins. 回答1: I'll expand a bit on my comment, which reads: I've just started using Lazy, and find that it's often indicative of bad design; or laziness on the part of the programmer.

.NET exception caught is unexpectedly null

五迷三道 提交于 2019-12-03 04:15:35
See below for an explanation of what is going on I have a really weird issue where the exception caught is null. The code uses MEF and tries hard to report composition errors. Using the debugger I can see the exception being thrown (an InvalidOperationException ) but when it is caught by the last catch block in the code below the ex variable is null. This is true both in the debugger and when executing the code normally. static T ResolveWithErrorHandling<T>() where T : class { try { IocContainer.Compose(Settings.Default.IocConfiguration); return IocContainer.Resolve<T>(); } catch

Getting only necessary plugins with MEF in .NET

淺唱寂寞╮ 提交于 2019-12-03 03:58:40
问题 I have IMessageSender interface. using System.ComponentModel.Composition; public interface IMessageSender { void Send(string message); } And I have two plugins that implements this interface. This is plugin.cs. using System.ComponentModel.Composition; using System.ComponentModel.Composition.Hosting; using System.Reflection; using System; [Export(typeof(IMessageSender))] public class EmailSender : IMessageSender { public void Send(string message) { Console.WriteLine(message); } } and this is

how to debug MEF exception?

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: we are currently using MEF (Managed Extensibility Framework, http://mef.codeplex.com/ ) and it throws out exceptions, with limited information to proceed on. is there a way to debug MEF exceptions? My exception is like this: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.RuntimeModule.GetTypes() at System.Reflection.Assembly.GetTypes() at System

How to persist MEF import and export information to disk

匿名 (未验证) 提交于 2019-12-03 02:15:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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 of the links gave me any idea how to: Extract all

Getting an export from an MEF container given only a Type instance

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a scenario where I have to get an export from my CompositionContainer instance but I only have a Type to work with; I don't know the type at compile time, hence I can't retrieve the exported object in the normal generic way. Normally you would do this: _container.GetExportedObject (); But in my case, I have this: Type someType = ... ; _container.HowDoIGetTheExport(someType); Any ideas? 回答1: Found the answer: var export = _container.GetExports(someType, null, null).FirstOrDefault(); 回答2: Create the call dynamically using Type