mef

Trying to figure out what this MEF Composition error means

二次信任 提交于 2019-12-23 09:58:47
问题 I have a question about the following exception I received trying to complete a call to .ComposeParts(this) : The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information. 1) The export 'CustomersModule.CustomerMenu (ContractName="ModLibrary.IMenu")' is not assignable to type 'System.Collections.Generic.IEnumerable`1[[ModLibrary.IMenu, ModLibrary, Version=1.0.0.0, Culture=neutral,

Visual studio 2010 colourizers, intellisense and the rest. Where to start!

柔情痞子 提交于 2019-12-23 09:32:13
问题 Ok, before I begin I realize that there is a lot of documentation on this subject but I have thus far failed to get even basic colourization working for VS2010. My goal is to simply get to a point where I can open a document and everything is coloured red, from here I can implement the relevant parsing logic. Here's what I have tried/found: 1) Downloaded all the relevent SDK's and such- Found the ook sample (http://code.msdn.microsoft.com/ookLanguage) - didn't build, didn't work. 2) Knowing

What happened to MEF type, “AttributedAssemblyPartCatalog”?

旧巷老猫 提交于 2019-12-23 09:07:25
问题 Many simple MEF examples (listed below) uses AttributedAssemblyPartCatalog . Hosting MEF in an application on CodePlex MEF page Simple Introduction to Extensible Applications with the Managed Extensions Framework by Brad Adams Managed Extensibility Framework Tutorial - MEF by David Hayden I have downloaded MEF source from CodePlex but still cannot find that type anywhere. What happened to AttributedAssemblyPartCatalog and what is the alternative way of creating a resolver? 回答1: They renamed

MEF 插件式开发之 小试牛刀

半腔热情 提交于 2019-12-23 05:38:37
MEF 简介 Managed Extensibility Framework 即 MEF 是用于创建轻量、可扩展应用程序的库。 它让应用程序开发人员得以发现和使用扩展且无需配置。 它还让扩展开发人员得以轻松地封装代码并避免脆弱的紧密依赖性。 MEF 让扩展不仅可在应用程序内重复使用,还可以跨程序重复使用。 在进行传统的 C/S 端开发,如果项目不是特别复杂,常规的开发模式还是可以应对的。但是一旦场景复杂度提升,一个小小业务功能的修改就需要更新整个客户端,这个对于开发者来说是不能忍受的。因此微软为我们引入了 MEF 的开发模式。允许我们将众多的业务模块拆分开来设计成独立的 DLL,然后由客户端来进行统一加载,这样就能解决上述我们所说的痛点。 实践出真知 创建一个高扩张的 MEF 框架涉及的技术点较多。为了方便初学者能较快理解,上手实践,我这里主要通过 3 个方面来进行相关叙述。 面向接口编程 如果你还不能理解什么是面向接口编程的话,那你应该还不能区分抽象类和接口之间的区别。其实在刚开始的时候我也不是很能理解,直到我看到了一句话: 抽象类规定了你是什么,接口规定了你能干什么 ,只要你能理解这句话,那么你应该就明白什么是面向接口编程,这种编程方式的好处是统一化了业务的暴露方式,方便外部使用。下面我们看一个简单的例子。 public interface IMessage { void

Deploying MEF parts

泄露秘密 提交于 2019-12-23 04:39:18
问题 I have built an executable shell that using MEF loads assemblies (MEF Parts) and displays / acts accordingly to the loaded functionality. I now want to deploy this application as a ClickOnce install. Does anyone have a strategy for this, at the moment I have seen 2 strategies. Build and installer for the parts and add it as a Redistributal Component to the shell application - this means that the 2 installations are basically welded together and it means that MEF is basically pointless Build a

MEF not loading a references again

我的未来我决定 提交于 2019-12-23 03:14:18
问题 I have a interface as follows: [InheritedExport(typeof(ITransform))] public interface ITransform {...} Now, I have two classes: namespace ProjectA { public class Transform:ITransform {....} } And namespace ProjectB { public class Transform:ITransform {....} } I am using DirectoryCatalog for loading each parts. Each project is compiled and their binaries(build output) location is given as an input to DirectoryCatalog for further composition. The code for fetching ITransform parts is as follows

MEF - [ImportMany] using ExportFactory<T> in WPF - .NET 4.0

佐手、 提交于 2019-12-23 02:36:54
问题 I have some part imports that I need to create multiple instances of. By searching around I decided I needed to use the ExportFactory class. Unfortunately, the ExportFactory class is not available in WPF by default, but luckily Glenn Block has ported the code. Originally, I was specifying the type when importing: [ImportMany(typeof(IMyModule))] public IEnumerable<Lazy<IMyModule, IMyModuleMetadata>> Modules { get; set; } I also created an export attribute: [MetadataAttribute] [AttributeUsage

How to recomposit empty DirectoryCatalog for MEF in WPF

和自甴很熟 提交于 2019-12-22 14:00:45
问题 I have an application with these step: startup application and ConfigureAggregateCatalog logon user to app download DLL MEF modules to directory called 'Modules' refresh directory catalog -- there is a problem I have empty directory 'Modules' after download dll i tried to load modules but without succes. There is an error on line where I called DirectoryCatalog.Refresh() System.ComponentModel.Composition.ChangeRejectedException was unhandled by user code Message=The composition remains

Loading plugins at runtime with MEF

本秂侑毒 提交于 2019-12-22 12:24:14
问题 My application allows users to write plugins (implementing IPlugin) that they can instantiate at runtime. On startup a directory of plugin .dlls is parsed, registering all the available plugins information. At runtime a GUI is provided that lets users create instances of any of the plugins. This works fine. But now I see MEF and hope I can do the same, but in a more elegant way codewise. What I got working so far with MEF : on startup I am doing an import of all plugins in a directory (that

WPF Prism: Problem with creating a Shell

核能气质少年 提交于 2019-12-22 11:28:40
问题 I just started learning Prism and trying to use it with MEF in a test WPF application. Based on "WPF Hands-On Lab: Get Started with the Prism Library" example in the Prism4 documentation, in a test WPF project I renamed MainWindow class to Shell . My Bootstrapper class has the following code (also based on the Lab example): class Bootstrapper : MefBootstrapper { protected override DependencyObject CreateShell() { return new Shell(); } protected override void InitializeShell() { Application