mef

MEF and ASP.NET MVC

走远了吗. 提交于 2019-12-21 04:31:48
问题 I want to use MEF with asp.net mvc. I wrote following controller factory: public class MefControllerFactory : DefaultControllerFactory { private CompositionContainer _Container; public MefControllerFactory(Assembly assembly) { _Container = new CompositionContainer(new AssemblyCatalog(assembly)); } protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { if (controllerType != null) { var controllers = _Container.GetExports<IController>(); var

MEF and ASP.NET MVC

家住魔仙堡 提交于 2019-12-21 04:31:04
问题 I want to use MEF with asp.net mvc. I wrote following controller factory: public class MefControllerFactory : DefaultControllerFactory { private CompositionContainer _Container; public MefControllerFactory(Assembly assembly) { _Container = new CompositionContainer(new AssemblyCatalog(assembly)); } protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { if (controllerType != null) { var controllers = _Container.GetExports<IController>(); var

MEF: What if I have multiple exports but need only one import?

◇◆丶佛笑我妖孽 提交于 2019-12-21 03:37:08
问题 I'm trying to wrap my mind around MEF. There is one thing I don't understand. Assume that I have an interface, named ISomething, which is a contract, and I have more than one assemblies in a folder that contains my application, and I have no idea how many ISomething implementations are in them, or which one contains one. If I create a host application in which I use MEF, and would like to get an ISomething, but only one, how does MEF decide which implementation it will give me? Or, similarly

Custom 'ExportFactory'

只愿长相守 提交于 2019-12-21 01:45:09
问题 A desktop application using MEF imports many 'ServiceProviders'. Each part (ServiceProvider) is a class inside a separate DLL. All DLLs are in 'Plugin" folder which is used by desktop application. Since I needed new Instances of my parts, ExportFactory was the best choice. The problem is my parts have constructors. I need pass some parameters into constructor of the part which is not supported by ExportFactory (MEF2, Preview2). I need something like this: // Each part has its own dependency

.NET exception caught is unexpectedly null

假如想象 提交于 2019-12-20 11:06:52
问题 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 {

MEF vs Mono.AddIn

帅比萌擦擦* 提交于 2019-12-20 10:33:59
问题 I'm developing a .NET 3.5 C# desktop application. It should be extensible via plug-ins. Are there any articles etc. discussing the differences between MEF and Mono.AddIn to help me make an informed decision? Or even better have you got experience with both of these frameworks and can comment on them? Thanks, Patrick 回答1: [NOTE: I work on MonoDevelop, which uses Mono.Addins, but I discussed the differences between MEF and Mono.Addins extensively with Glenn Block from the MEF team last week]

How to discover new MEF parts while the application is running?

情到浓时终转凉″ 提交于 2019-12-20 08:46:01
问题 I'm using MEF to load plugins in my app. Everything works, but I want new parts to be discovered when they are dropped into my app folder. Is this possible? DirectoryCatalog has a Changed event but I'm not sure how it works. This is my code right now: public sealed class RevealerFactory { private static readonly Lazy<RevealerFactory> lazy = new Lazy<RevealerFactory>(() => new RevealerFactory()); public static RevealerFactory Instance { get { return lazy.Value; } } private FileSystemWatcher

Which parts of MEF should be customized for dynamic loading of plug-ins in a distributed application

时光怂恿深爱的人放手 提交于 2019-12-20 03:17:01
问题 My simulation application will be using plug-ins to provide the simulation algorithms and data structures for the storage of the simulation data. The application consists of two parts. First is the host application which provides the UI (either as WPF UI or as plug-in to a CAD application). This application handles all interaction with the user but does not perform any of the simulation calculations, neither does it store any of the simulation data. The second part is the data application

MEF - Get assembly from embedded DLL

隐身守侯 提交于 2019-12-20 01:11:48
问题 I am using MEF to create "plugins" for my WPF application. Some of these plugins I want to embed directly into the EXE file as the EXE needs to be standalone. I am using Costura by Fody to embed the resource along with all my other references. As the exe file needs to be standalone I am unable to create a directory for these plugins and use the DirectoyCatalog Is there anyway I can either load the assembly from the embedded resource, or simply specify the assembly name such as: catalog

Overwriting dlls in MEF

大城市里の小女人 提交于 2019-12-19 10:22:13
问题 Right now, I'm trying to separate out a set of constantly changing classes into their own dll and dynamically load them using MEF. My problem is that whenever I try and overwrite the dll while the app is running, it says it's in use. Is there anyway to configure MEF to let me overwrite the dll and pick up the changes while the app is still running? 回答1: This is not an MEF issue - it is your appdomain standard setup that locks the DLL's touched. Check http://www.vistax64.com/powershell/26164