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

New Post: Deprecating obsolete NuGet packages


New Post: Why does RegistrationBuilder exclude parts decorated with a metadata attribute?

$
0
0
Did you ever get an answer on this?

New Comment on "FileExplorer"

$
0
0
I really liked this application. I am new to MEF, is it possible to get the full source code of this app?

Reviewed: Using MEF with ASP.NET MVC 3 Sample Code (août 19, 2014)

$
0
0
Rated 2 Stars (out of 5) - Works on MVC 3 not 5!

New Post: Is there a collection of applications that use MEF as a viable extension framework?

$
0
0
I am evaluating MEF (and MAF) for extensibility of an imaging application. I am new to both. Is there a collection of applications that use MEF as a viable extension framework? Can anyone help to list what work and what do not work?

Thanks in advance.

New Post: Replace(Remove/Add) the shared object in MEF container

$
0
0
This may be simple but as I am new to MEF arena that is why I am having some difficulty to figure out the solution to my problem.

I am working on an application using WPF and Prism with MEF as DI container. I want to tie my object (i.e. RuleFile) with each application instance by associating it with the file say RuleFile1.ruleapp. Therefore I have decorated it with attribute [PartCreationPolicy(CreationPolicy.Shared)] to treat it as singleton so that it remains same throughout the application with each application instance.
[Serializable()]
[Export]    
[PartCreationPolicy(CreationPolicy.Shared)]
public class RuleFile : NotifyPropertyChanged, IRuleFile { }
Next, at the time of ViewModel [ImportingContructor] as shown below, the object is same as desired.
[ImportingConstructor]
public RuleViewModel(RuleFile ruleFile)

[ImportingConstructor]
public SchemaViewModel(RuleFile ruleFile)
Until now everything is smooth.

Now the challenging part is how to replace this object with the deserialized one in the MEF container?

This is the code effort that i was trying to do but no luck:
public void Load()
{
    var catalog = new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly());
    var container = new CompositionContainer(catalog);
    var myExport = container.GetExport<RuleFile>();
    container.ReleaseExport(myExport);

    RuleFile = SerializationHelper.DeserializeFromFile<RuleFile>(Constants.RuleFilePath);
    container.ComposeExportedValue<RuleFile>(RuleFile);
}

New Post: MEF for WinRT 8.1 Store Apps?...

$
0
0
Hi

Was wondering if MEF 2 V1.0.27 Microsoft.Composition support Windows Store Apps 8.1 and so you have as App example?

Reviewed: MEF Analysis Tool (mefx) for .NET 4.0 Beta (九月 15, 2014)

$
0
0
Rated 5 Stars (out of 5) - 太难找到下载了。非要回复才可以吗

New Post: MEF for WinRT 8.1 Store Apps?...

$
0
0
Cancel that! I have the latest working!

New Post: Why is #if WINDOWS_PHONE_APP directive not working?...

$
0
0
IDE: VS Express 2013 for Windows
Project: Universal
IoC: MEF
Target OS: 8.1

Hi,

In testing on my Windows Phone App on my Device the #if WINDOWS_PHONE_APP directive is not working in my ViewModel, I'm injecting my ViewModels into the DataContext of the my Page's like this.

Injection:
[Export(typeof(HubPage))]
public sealed partial class HubPage : VisualStateAwarePage
{
    public HubPage()
    {
        this.InitializeComponent();
        Debug.WriteLine("HubPage InitializeComponent");

#if WINDOWS_PHONE_APP
            Debug.WriteLine("directive WINDOWS_PHONE_APP is defined...");
#elif WINDOWS_APP
            Debug.WriteLine("directive WINDOWS_APP is defined...");
#else
            Debug.WriteLine("Error directive WINDOWS_PHONE_APP/WINDOWS_APP not defined...");
#endif

    }

    [Import]
    public NathsarTS.UILogic.Interfaces.IHubPageViewModel ViewModel
    {
        set
        {
            this.DataContext = value;
        }
        get
        {
            return DataContext as NathsarTS.UILogic.Interfaces.IHubPageViewModel;
        }
    }

    /// <summary>
    /// Called when a part's imports have been satisfied and it is safe to use.
    /// </summary>
    [OnImportsSatisfied]
    public void OnImportsSatisfied()
    {
        // IPartImportsSatisfiedNotification is useful when you want to coordinate doing some work
        // with imported parts independent of when the UI is visible.
        Debug.WriteLine("HubPage OnImportsSatisfied instantiation");

        this.ViewModel.ObserverHubPageLoadedEventArgs =
            Observable.FromEventPattern<object, RoutedEventArgs>(this.pageRoot, "Loaded");
        this.ViewModel.DisposableHubPageLoadedEvent =
            this.ViewModel.ObserverHubPageLoadedEventArgs.Subscribe(evt => this.ViewModel.OnPageRootHubPageLoadedEvent(evt.Sender, evt.EventArgs));

        //NathsarTS.UILogic.Interfaces.IObservableService ObservableService = ServiceLocator.Current.GetInstance<NathsarTS.UILogic.Interfaces.IObservableService>();
        //this.ViewModel.NavigationHelper = new NathsarTS.Common.Logic.NavigationHelper(this);
        //this.ViewModel.NavigationHelper.LoadState += this.ViewModel.NavigationHelperLoadState;
    }
}
In my HubPage (above) and App (below) I check to see if the directive is defined:
        public App()
        {
#if WINDOWS_PHONE_APP
            Debug.WriteLine("directive WINDOWS_PHONE_APP is defined...");
#elif WINDOWS_APP
            Debug.WriteLine("directive WINDOWS_APP is defined...");
#else
            Debug.WriteLine("Error directive WINDOWS_PHONE_APP/WINDOWS_APP not defined...");
#endif
            this.InitializeComponent();
            this.RequestedTheme = ApplicationTheme.Light;
        }
Results: directive WINDOWS_PHONE_APP is defined...

In my ViewModel I check again after the Page is Loaded:
        public async void OnPageRootHubPageLoadedEvent(object sender, RoutedEventArgs args)
        {
            Debug.WriteLine("OnPageRootHubPageLoadedEvent instantiation");

#if WINDOWS_PHONE_APP
            Debug.WriteLine("OnPageRootHubPageLoadedEvent (Phone) instantiation");

            var sampleDataGroups = await SampleDataSource.GetGroupsAsync();
            this.DefaultDataModel["Groups"] = sampleDataGroups;
#elif WINDOWS_APP
            Debug.WriteLine("OnPageRootHubPageLoadedEvent (Windows) instantiation");

            var sampleDataGroup = await NathsarTS.Common.DataModel.SampleDataSource.GetGroupAsync("Group-4");
            this.DefaultDataModel["Section3Items"] = sampleDataGroup;
#else
            Debug.WriteLine("Error directive WINDOWS_PHONE_APP/WINDOWS_APP not defined...");
            await Task.FromResult<object>(null);
#endif
        }
Results: Error defining Windows/Phone...

I'm assuming its because the ViewModel become apart of the XAMLDataContext? If so, looks like I may have to use a property setting for this?

New Post: Why is #if WINDOWS_PHONE_APP directive not working?...

$
0
0
As an result of the directive not available after injection, I had to create a BooleanProperty in my ViewModel and set it during __OnImportsSatisfied__():
 /// <summary>
        /// Called when a part's imports have been satisfied and it is safe to use.
        /// </summary>
        [OnImportsSatisfied]
        public void OnImportsSatisfied()
        {
            // IPartImportsSatisfiedNotification is useful when you want to coordinate doing some work
            // with imported parts independent of when the UI is visible.
            Debug.WriteLine("HubPage OnImportsSatisfied instantiation");

#if WINDOWS_PHONE_APP
            Debug.WriteLine("directive WINDOWS_PHONE_APP is defined...");
            this.ViewModel.Windows_Phone_App = true;
#elif WINDOWS_APP
            Debug.WriteLine("directive WINDOWS_APP is defined...");
            this.ViewModel.Windows_Phone_App = false;
#else
            Debug.WriteLine("Error directive WINDOWS_PHONE_APP/WINDOWS_APP not defined...");
#endif
        }

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

$
0
0
Hi all,

Does anyone know if this has been fixed in .NET 4.5 or higher?

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

http://stackoverflow.com/questions/4020532/mef-unable-to-load-one-or-more-of-the-requested-types-retrieve-the-loaderexce

Couldn't find anything in the discussions here and, in my case, it happens only under certain conditions (running a whole bunch of unit tests) and it's not very easy to copy the project and do a test with 4.5 to find out.

Thanks.

Cheers, Bezz

New Post: MEF2: Instance Registration

$
0
0
Hello,

Same question ... how do we register existing instances into the container?


Adrien.

Created Unassigned: MEF Extension Bug – unexpected module initialization [14619]

$
0
0

__ModularityWithMef.Desktop Sample Application__

![Image](http://www.global-webnet.net/blog/image.axd?picture=001-BadLog.jpg)

The MefModuleManager.OnImportsSatisfied() is executing LoadModulesThatAreReadyForLoad() on line 93. Since the ModularityWithMef.Desktop application imports IModuleManager the modules are beling loaded prior the Shell constructor firing.

If you remark out this line you get the following (expected) results:
![Image](http://www.global-webnet.net/blog/image.axd?picture=003-GoodLog.jpg)

Blogged in more detailed [HERE](https://www.global-webnet.net/blog/post/2014/11/06/MEF-Extension-Bug–unexpected-module-initialization.aspx)

Edited Unassigned: MEF Extension Bug – unexpected module initialization [14619]

$
0
0

__ModularityWithMef.Desktop Sample Application__

![Image](http://www.global-webnet.net/blog/image.axd?picture=001-BadLog.jpg)

The MefModuleManager.OnImportsSatisfied() is executing LoadModulesThatAreReadyForLoad() on line 93. Since the ModularityWithMef.Desktop application imports IModuleManager the modules are being loaded prior the Shell constructor firing.

If you remark out this line you get the following (expected) results:
![Image](http://www.global-webnet.net/blog/image.axd?picture=003-GoodLog.jpg)

Blogged in more detailed [HERE](https://www.global-webnet.net/blog/post/2014/11/06/MEF-Extension-Bug–unexpected-module-initialization.aspx)

Edited Unassigned: MEF Extension Bug – unexpected module initialization [14619]

$
0
0

__ModularityWithMef.Desktop Sample Application__

![Image](http://www.global-webnet.net/blog/image.axd?picture=001-BadLog.jpg)

The MefModuleManager.OnImportsSatisfied() is executing LoadModulesThatAreReadyForLoad() on line 93. Since the ModularityWithMef.Desktop application imports IModuleManager the modules are being loaded prior to the Shell constructor firing.

If you remark out this line you get the following (expected) results:
![Image](http://www.global-webnet.net/blog/image.axd?picture=003-GoodLog.jpg)

Blogged in more detailed [HERE](https://www.global-webnet.net/blog/post/2014/11/06/MEF-Extension-Bug–unexpected-module-initialization.aspx)

New Post: Resolver assembly file plug-ins in System.Composition (a la DirectoryCatalog)

$
0
0
Hi,
I have the same issue.
Trying to implement kind of plug in architecure using lightweight mef (for wp8.1), and i wonder what is the way to implement DirectoryCatalog with System.Composition?

I want to enable external users to export their own plug ins (of course, based on my interface) and load them dynamiclly, but i can't find a simple way to do this using the ComposistionHost.

Can you please advise?
Thanks!

Created Unassigned: Performance issue caused by scanning for exported members [14620]

$
0
0
We have a performance issue with the composition of types from assemblies which have many types, each of them having many members. We never(!) use the [Export] attributes on members. We only use the [Export] attributes on (few) types. We would like to have an option to turn off discovery of exports from members (field, properties, methods) entirely.

This could be implemented by making the BindingFlags used for reflection of members configurable and skip/ignore all members if they are set to BindingFlags.Default (0).

Some performance numbers:
We have 19 exports in 13 assemblies with a total of 3,093 types/46.459 members => the first composition takes approx. 3.200(!) ms.
When we ignore the members, it only takes 14(!) ms.

New Post: Importing Multiple InheritedExport Interfaces

$
0
0
Hello, newby MEF here:

I have 2 interfaces to classlibraries I want to compose with my main application. What i am trying to achieve is a directory of .dlls that I can update/manage for the application as a whole.

InheritedExport]
public interface IObject1
{
  method1();
  method2();
}

InheritedExport]
public interface IObject2
{
  method3();
  method4();
}

Now in the main application thread, I get an error duplicate 'Import' attributes. I want to use both objects in my main application, I just don't know how to import them properly.
#region Imports section

        [Import(typeof(Object1), AllowRecomposition = true)]
        [Import(typeof(Object2), AllowRecomposition = true)]

        private Object1 _obj1;
        private Object2  _obj2;
   #endregion

 private void Compose()
        {
            dirCatalog = new DirectoryCatalog(@"D:\Folder");
            AssemblyCatalog assemblyCat = new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly());
            AggregateCatalog catalog = new AggregateCatalog(assemblyCat, dirCatalog);
            CompositionContainer container = new CompositionContainer(catalog);
            container.ComposeParts(this);
        }

Reviewed: MEF 2 Preview 5 (十二月 04, 2014)

$
0
0
Rated 5 Stars (out of 5) - Try to use it in my project. I hope it is useful!
Viewing all 265 articles
Browse latest View live