mef

Getting a Type Assembly in Windows 8

风格不统一 提交于 2019-12-06 20:04:30
问题 I'm trying to use MEF in Windows 8. In order to build up my AssemblyCatalog for the container, I need a reference to the assembly. In the past, I would have just done this: var catalog = new AssemblyCatalog(typeof(App).Assembly); Mysteriously, the Assembly property no longer exists on the Type object. Anybody know of a good work around? Is there another way to get the assembly? I could load it using Assembly.Load , but I would need the name of the assembly. I can't get that from the type

WPF Prism: Problem with creating a Shell

大城市里の小女人 提交于 2019-12-06 10:39:56
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.Current.MainWindow = (Shell)this.Shell; Application.Current.MainWindow.Show(); } ... App.xaml.cs code:

How to recomposit empty DirectoryCatalog for MEF in WPF

懵懂的女人 提交于 2019-12-06 09:55:47
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 unchanged. The changes were rejected because of the following error(s): The composition produced multiple

MEF parts configuration, where to store?

烂漫一生 提交于 2019-12-06 03:46:12
问题 In ASP.NET , .NET 4.0 , MEF , I put all parts in a folder and importing them using DirectoryCatalog . Everything is fine. Some of part have related configurations. I don't want put them in web.config . Maybe a good approach be a config file just beside the part with a .config added to the end. What is the best way for storing part configuration ? 回答1: I was able to create a separate config file for each DLL and successfully was able to read the keys. But when I tried to create a custom config

Managed Extensibility Framework (MEF) vs. Composite UI Application Block (CAB)

不羁岁月 提交于 2019-12-06 02:49:10
问题 We are currently looking at either using CAB or MEF for our next application. I didn't see any examples on codeplex of how event brokering is handled for sibling control communication, maybe I missed it. How does inter-control communication work in MEF? Also, we are planning on using Infragistics which has provided additional components for the CAB framework. How well will Infragistics controls integrate into MEF? Overall, is MEF worth pursuing for a decently large, 15,000 hours of strictly

Use classes from another MEF assembly without referencing to it

╄→尐↘猪︶ㄣ 提交于 2019-12-06 02:03:05
I have 2 MEF components. Let it be component A and component B. What I need is to be able to access a class from component B in component A without referencing to it. Then I would like to instantiate object of the class manually. Currently I see MEF allows instantiating an object automatically using [Import]. It uses interface which requires to be referenced to. Can I use data types from another assemblies without referencing to it? Is there such mechanism supported by MEF? There are a couple of ways to do this. First, you need to define a common interface that both assemblies understand. This

Is it safe to store an ObjectContext in a thread static variable in ASP.NET?

限于喜欢 提交于 2019-12-05 21:52:57
I've read that I should store an ObjectContext in HttpContext.Current in order to share my ObjectContext across different services/repositories that are called in a request. I'm wondering if it is safe to use an ObjectContext with the [ThreadStatic] attribute on a static class variable instead. Is that a safe thing to do? Is each request processed in its own thread? Heinzi No, there can be multiple requests in the same thread and, more importantly, one request can be processed in multiple threads . This is called thread agility , and you will run into problems when you store stuff in thread

C# Singleton Pattern and MEF

坚强是说给别人听的谎言 提交于 2019-12-05 19:26:44
问题 I have a question about the Singleton Pattern and MEF. I'm new in implementing MEF Plugins and I haven't found an answer. Is it possible to provide only one instance of a class through a MEF implemented Plugin? My old class is something like this: #region Singleton /// /// This class provide a generic and thread-safe interface for Singleton classes. /// /// The specialized singleton which is derived /// from SingletonBase<T> public abstract class Base where T : Base { /* the lock object */

MEF, why are identical duplicates of one and the same exported plugin created?

十年热恋 提交于 2019-12-05 18:53:30
(1) Using the code below I get exactly 2 items in my containers of one and the same exported plugin and I wonder why: (2) Additional question which I really cannot implement: How can I extend the framework to handle different plugin types (such as having several imports of different types, or one import that stores all plugins in a dynamic IEnumerable or so). I want to provide in my static wrapper class one generic method that returns the discovered plugin as a function of type and matching meta data. The exported plugin (which resides in a separate dll and whose location is pointed to when

What does [PartCreationPolicy(CreationPolicy.Shared)]

末鹿安然 提交于 2019-12-05 18:24:48
问题 What does [PartCreationPolicy(CreationPolicy.Shared)] mean? 回答1: To add to Julien's answer, I think conceptually you can think of it as a Singleton. 回答2: It means that, when requesting an instance of a class decorated with [PartCreationPolicy(CreationPolicy.Shared)] , the CompositionContainer will always return the same instance of this class and not create a new one. [Export] [PartCreationPolicy(CreationPolicy.Shared)] class Foo { } The above class will give the following result: private