mef

How to read MEF metadata in a DLL plugin without copying the entire DLL into memory?

独自空忆成欢 提交于 2019-12-19 08:17:38
问题 Background: I'm interested in using MEF to provide a plug-in architecture in a WinForm application using C# with .NET 4.0, but I am not clear on a couple of things. First: I have not worked at all with building DLLs yet in C#, and I'm a little fuzzy on the concept of DLL Assemblies and how a DLL is normally loaded into memory ( meaning, all at once or in pieces as needed ) Intent: The program will be a machine hardware control framework, and will be made up of a primary WinForm GUI that is a

MEF Constructor Parameters with Multiple Constructors

﹥>﹥吖頭↗ 提交于 2019-12-19 06:27:06
问题 I'm starting to use MEF, and I have a class with multiple constructors, like this: [Export(typeof(ifoo))] class foo : ifoo { void foo() { ... } [ImportingConstructor] void foo(object par1) { ... } } I am using catalog.ComposeExportedValue() when composing to supply the par1 value to second constructor: ... catalog.ComposeExportedValue(par1Value); catalog.ComposeParts(this); ... To hold the components I'm using: [ImportMany(typeof(ifoo))] public List<Lazy<ifoo, ifoometadata>> FooList { get;

Are MEF exports cached or discovering every time on request?

会有一股神秘感。 提交于 2019-12-19 02:59:04
问题 If I have one type MyClass, register with [Export(typeof(Myclass))] attribute, and [PartCreationPolicy(CreationPolicy.Shared)] or [PartCreationPolicy(CreationPolicy.NonShared)] and later trying to call compositionContainer.GetExportedValue<Myclass>() multiple times. Question: with the first call, I will get my registered class via MEF - llokup all registered assemblies, then trying to find one registered contract. Question is about second time and so on - will MEF do global lookup again or it

How can I leverage MEF in my MVVM application? [closed]

旧时模样 提交于 2019-12-18 18:32:33
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Can anybody give me a simple wpf application using mef and following mvvm pattern. I have looked a lot on the internet but i found

What is the best way of using NLog with MEF?

旧时模样 提交于 2019-12-18 16:59:14
问题 I am wondering what is the best way to use NLog with Managed Extensibility Framework (MEF)? I have an application that support plugins using MEF architecture (Import and Exports etc) I want to add logging capability to my application. As a logging component I want to use NLog. What would you recommend? 1. Create a wrapper for NLog, i.e. additional plugin that configures NLog and exports functions like void Log(string level, string message) that other plugins importing 2. Every plugin should

MEF = may experience frustration?

▼魔方 西西 提交于 2019-12-18 12:36:57
问题 UPDATE As I've tried to get MEF working throughout my application, I'm coming across more an more places where I just don't get why it's not automatically creating my library when I expect it to. I think it all comes back to what Reed was saying about needing MEF to create everything. So right now, I have an XML reader class that needs to use my CandySettings, but even though its ICandySettings property has the [Import] attribute, it doesn't get imported. First I found out that [Import] doesn

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

本小妞迷上赌 提交于 2019-12-18 12:23:49
问题 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<IMyType>(); 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)

MEF: “Unable to load one or more of the requested types. Retrieve the LoaderExceptions for more information”

て烟熏妆下的殇ゞ 提交于 2019-12-18 11:07:15
问题 Scenario: I am using Managed Extensibility Framework to load plugins (exports) at runtime based on an interface contract defined in a separate dll. In my Visual Studio solution, I have 3 different projects: The host application, a class library (defining the interface - "IPlugin") and another class library implementing the interface (the export - "MyPlugin.dll"). The host looks for exports in its own root directory, so during testing, I build the whole solution and copy Plugin.dll from the

How to remove MEF plugins at runtime?

我是研究僧i 提交于 2019-12-18 10:59:20
问题 I have a MEF-based application that can be customized with plugins. This application has several imported parts, and I want to remove some of them at runtime (to be able to delete the .dll that contains them) when a user decides to get rid of that plugin. CompositionBatch would do what I need, but it needs ComposablePart instances as input parameters for RemovePart() method, and I only have plain objects that implement ISomething interface, or ComposablePartDefinition instances in the

MEF: a replacement for PRISM?

懵懂的女人 提交于 2019-12-18 10:53:19
问题 To what extent, if any, is MEF a replacement for PRISM? 回答1: Edit: Do not read this answer. It is embarrassingly wrong. I am fail. Read Glenn Block's below. It's not obvious, but this is the same question: Managed Extensibility Framework (MEF) vs. Composite UI Application Block (CAB) Consensus in the duplicate post is that MEF and Prism provide the same basic set of functionality in different ways, except that Prism provides the Event Aggregator, which is a pub-sub means of communication