Quantcast
Channel: Managed Extensibility Framework
Viewing all 265 articles
Browse latest View live

New Post: MEF distributions

$
0
0
The MEF team has been really quite, you can see that the articles are over year old.
The last commit here was at Jul 20, 2012.

Where can we see what is going on with MEF team and what the future plans are?
I put MEF in the core of our application and it is very important to me to see where Microsoft is going with it.

Thank you,
Ido.

New Post: MEF Scope and Provider

$
0
0
Hi,
Is there a way to map MEF to use provider instead of directly create the part by itself?
The reason I ask it is because the scope you are allow today are governed by the consumer of the part. What I mean is that the consumer ask for a part using ExportFactory<Part> and it is the one responsible for creating the part and disposing it.

In web application, for example, I have two scopes I want to support: request and session.
I look at Google Guice which remind me of MEF just for the Java world. They also define request and session scope for web application and they achieve it using Providers. They allow to map a requested part to provider, and not directly to implementation, and that way the provider is responsible for creating a new part or return already built part.
The implementation of session scoped provider simply cache the part in the current session dictionary, and the request is cached in the request dictionary.

If I'll be able to use providers with MEF I'll be able to decide on the scope from the declaring side and the consumer side will simply have a "just-works" experience without troubling itself with the scope details.

I hope I made myself clear.

Thank you,
Ido.

New Post: MEF distributions

$
0
0

Hi Ido,

The team has been focused on other priorities and working on enabling some longer term goals of the framework that are not specific to MEF, which I cannot talk about at this point in time. Please be assured that it is supported by us. We have some ideas on where we want to invest in MEF and we would love to share them out and get feedback as soon as we can get it to a point where we can execute on it.

Thanks for your patience and endorsment.

cheers

-alok

New Post: The component (unknown) cannot be created outside the HttpContext sharing boundary.

$
0
0
Hi,
I run into this exception this morning because I find out that when I update from old CodePlex code to Microsoft.Composition NuGet package the sharing policy changed and I didn't set the sharing right using the new ConventionBuilder.

The reason is happen is because I've set part A to be shared (singleton) and part A import in ctor part B and part B was HttpContext boundary shared.

Why did we get unknown in there? That made the debug a bit more difficult.

Ido.

New Post: ExportProperty

$
0
0
Hi,
The class PartBuilder<T> has a method ExportProperty.
Can you please publish example of how to us it?

The Export Attribute model had the ability to export a part from a property which allow the provider side to run arbitrary code to provide the part. How can I get the same result using ConventionBuilder?

Thank you,
Ido.

New Post: Parts get constructed multiple times

$
0
0
I want to use MEF in my WP8 app, so I grabbed the OOB sources and recompiled adding only the WP8 target to the PCLs - nothing else has been changed.

My problem is that I have a couple of exports of which two of them require the same import. What happens is that the import in question gets constructed twice - contrary to what I would have expected. In the assemblies produced, there is no PartCreationPolicy - and I would have expected that the default sharing would been preserved.

Any ideas how to solve this?

Thanks,

New Post: Parts get constructed multiple times

$
0
0
Hi did you try using Microsoft.composition on nuget. ? It is mef for the win8.


New Post: Parts get constructed multiple times

$
0
0
I did. But, I want this to work for WP8.

I did however, find the solution. For some reason I had gotten things wrong that parts are by default non-shared, and then I found the [Shared] attribute, which solved my problem. Thanks for the reply, tough :)

Created Unassigned: The component (unknown) cannot be created outside the HttpContext sharing boundary. [14608]

$
0
0
Hi,
I run into this exception this morning because I find out that when I update from old CodePlex code to Microsoft.Composition NuGet package the sharing policy changed and I didn't set the sharing right using the new ConventionBuilder.

The reason is happen is because I've set part A to be shared (singleton) and part A import in ctor part B and part B was HttpContext boundary shared.

Why did we get unknown in there? That made the debug a bit more difficult.

Ido.

New Post: MEF and AppDomain

New Post: MEF and Shadow Copy Files Sample?

New Post: Simple start-to-end example for MEF2?

$
0
0
I'm trying to eval MEF2 right now, but I'm having tons of problems figuring it out due to a number of factors (e.g., MEF2 is in flux, searches bring up MEF1 results, I'm dumb, etc).

My goals are exceedingly simple, so I'm hoping that someone who understands how it fits together can point me in the correct direction.

What I've got so far is a very simple console solution with two projects, one that hosts a plugin interface and one that implements it. The implementing project throws its built DLL into the bin folder of the plugin host, so that after building the assembly containing the DLL should be easily discoverable. The plugin host knows nothing about the implementer, other than any implementers are going to be accessible in the bin folder.

My goal is to do the following:
  1. Run the plugin host console application
  2. Spin up MEF2, telling it that I want types that implement IPlugin (original, I know)
  3. Get new instances of all types that implement IPlugin every time I ask MEF2 for it
  4. Have a beer, because MEF is doing all the heavy work for me, and I'm done
What I have done is create my two projects, and in the plugin host, and a bunch of MEF2 code that doesn't do anything.

So, given the following plugin defintion
    public interface IPlugin
    {
        void Run();
    }
and the given console program:
class Program
{
    static void Main(string[] args)
    {
        var plugins = GetPluginsViaMef2LolKThx();
        foreach(var plugin in plugins)
            plugin.Run();
        Console.ReadLine();
    }

    private static IEnumerable<IPlugin> GetPluginsViaMef2LolKThx()
    {
        throw new NotImplementedException("HALP!");
    }
}
could somebody do me a major solid and tell me how I can implement that method?

New Post: Simple start-to-end example for MEF2?

$
0
0

William,

I am assuming that you are using the version of MEF that comes with .Net 4.5. Here are a couple of things to get you started.

Let’s assume that you have two classes that implement IPlugin

[Export(typeof(IPlugin))] //Add these attributes to make them discoverable to MEF.

Plugin1: IPlugin In Plugin1.dll

[Export(typeof(IPlugin))]

Plugin2: IPlugin In Plugin2.dll

In your Main in hosting application, you need to define a DirectoryCatalog with the path where the binaries are dropped.

var directoryCatalog=new DirectoryCatalog(“<BINPATH>”)

var container=new CompositionContainer(directoryCatalog)

IEnumerable<IPlugin> plugins= container.GetExportedValues<IPlugin>(); // GetPluginsViaMef2LolKThx[This is the implementation of your method

plugins should have Plugin1 and Plugin2

In case you want your plugins to be completely oblivious to the use of MEF, you can use registration builder to define rules.

var builder=new RegistrationBuilder();

builder.ForTypesDerivedFrom<IDisposable>().ExportInterfaces();

and pass that in to the DirectoryCatalog as follows.

var directoryCatalog=new DirectoryCatalog(“<BINPATH>”,builder)

hope that answers your question. (Excuse the email formatting)

cheers

-alok

New Post: Simple start-to-end example for MEF2?

$
0
0
Appreciate the example. I was attempting to use the cut down version of MEF2 available via a nuget package

https://www.nuget.org/packages/Microsoft.Composition

Now, that stripped down version doesn't have types such as DirectoryCatalog. So I think I understand why I was having such a hard time getting a hang of MEF2.

I suppose I'll just skip the NuGet version and go with the one in the 4.5 BCL.

Thanks again.

New Post: Simple start-to-end example for MEF2?

$
0
0

William,

for the nuget version of MEF you could use the method in ContainerConfiguration WithAssemblies( ) method.

You would need to pull the assemblies on your own in that case. The attributes should work the same way and the equivalent for registrationbuilder is conventionbuilder

hope that helps

cheers

-alok


New Post: How best to access an Exported Property from an MEF Component at run-time?

$
0
0
I have a WPF application that uses an extensive set of MEF components, some of which have user interface elements or that need to provide data for use in xaml controls. My problem is how best to load data at run-time and use an Export property (or Method) to provide the dynamic data for use on a user interface element such as a ComboBox or DataGrid. There are two scenarios I must satisfy:
1.Populating a control, such as a ComboBox, at the point when the MEF component is instantiated and loaded, using data from either a configuration file or from a database query.
2.Populating a control, such as a DataGrid, with data resulting from a database query filtered by user input, such as the selection of a single item from the ComboBox loaded in #1.

Any pointers would be helpful.

Thanks,

Jim

New Post: PartMetadataAttribut vs. ExportAttribute and ExportMetadataAttribute

$
0
0
I have created my own custom FilteredCatalog, like that shown on the MEF CodePlex site (https://mef.codeplex.com/wikipage?title=Filtering%20Catalogs&referringTitle=Guide) using the PartMetadataAttribute like so:

[PartMetadata("KeyName", "KeyValue", Export]

In the documentation for the PartMetadataAttribute it doesn't show the 'Export' or anything else for that matter, other than the Key and Value.

My question is this: Does the use of the 'Export' in the PartMetadataAttribute accomplish the same thing as using an explicit [ExportAttribute]? Can or should I use both?

Thanks

New Post: Binding a DataGrid ItemSource to an ObservableCollection contained in a MEF Component

$
0
0
I have an application that is comprised primarily of MEF components. Components that have user interface elements construct the wpf markup in code and return an Element to the main application through an Export (a property). One of the components uses a DataGrid whose ItemSource I want to bind to an ObservableCollection contained in a DataContext that is accessible only to the component itself, not as an Export. If I Export the property in the component that returns the wpf markup will the Binding still remain? In other words, once the markup has been returned to the main window and used in a ContentPresenter, will changes made internally to the bound data (within the MEF component) be reflected in the DataGrid? Or do I need to Export another property that returns an ObservableCollection and bind it to the DataGrid outside of the component? (This approach defeats the purpose of using the MEF component as I don't want to have to know about any internals such as that the component has a DataGrid.)

If further explanation is needed, let me know.

Thanks

New Post: What does ReleaseExport really do?

$
0
0
I'm having the same issue. Anyone found any solutions for this? Seems like a pretty major flaw to me.

Created Unassigned: Bug in CompositionContract Equals [14609]

$
0
0
The Equals method of the CompositionContract in the System.Composition.Runtime assembly has a bug. The Equals method will eventually internally call ConstraintEqual, which is ultimately where the bug lies.

ConstraintEqual compares two dictionaries. In most cases, there are checks for null dictionaries and null values; however, there is one uncovered case that will cause a NullReferenceException.

The following covers most scenarios:
```
if ( ( ( pair.get_Value() == null ) && ( obj2 != null ) ) || ( ( obj2 == null ) && ( pair.get_Value() != null ) ) )
{
return false;
}
```
However, if BOTH values are null, then processing continues. Eventually, you'll reach the final evaluation:
```
else if ( !pair.get_Value().Equals( obj2 ) )
{
return false;
}
```
Here lies the problem. If both of the values are null, then the Equals method is invoked on the result of KeyValuePair<,>.Value, but you'll get a NullReferenceException. The simple fix is to use the either the "==" operator or the static Object.Equals( Object, Object ) method.

This problem can arise any time you have metadata for a contract that is used multiple times and one or more of the metadata values is null.

I discovered this by expanding upon the "setting composition" example and adding a DefaultValue property to be included in the metadata. This enables composing settings, but also allows a fallback value if the setting is not present (and perhaps not required). In most scenarios, all works as expected; however, if the same setting has been resolved and is subsequently evaluated for reuse (by the lifetime context), the comparison of CompositionContract will fail due to the bug described if, and only if, the DefaultValue metadata value is null.
Viewing all 265 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>