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

New Post: Efficient Scoping in MEF2


New Post: An explanation about ChildContainer - ExportFactory - CompositionScopeDefinition

Created Unassigned: Defining Scope in MEF with CompositionScopeDefinition [14607]

$
0
0
You cannot use CompositionScopeDefinition in conjunction with an AssemblyCatalog.

http://stackoverflow.com/questions/16943121/defining-scope-in-mef-with-compositionscopedefinition?answertab=votes#tab-top

New Post: Caller context

New Post: Manually loading module using InitializeModules?...

$
0
0
Hi,

I the source project of Prism Splash Screen Module and I want to convert this example of loading modules to Mef:
  public class Bootstrapper : UnityBootstrapper
  {
    protected override void ConfigureContainer()
    {
      Container.RegisterType<IShell, Shell>(new ContainerControlledLifetimeManager());
      base.ConfigureContainer();
    }

    protected override DependencyObject CreateShell()
    {
      var shell = Container.Resolve<IShell>();
      return shell as DependencyObject;
    }

    #region Private Properties
    private IEventAggregator EventAggregator
    {
      get { return Container.Resolve<IEventAggregator>(); }
    }
    #endregion

    protected override void InitializeModules()
    {
      IModule splashModule = Container.Resolve<Splash.Module>();
      splashModule.Initialize();

      EventAggregator.GetEvent<MessageUpdateEvent>().Publish(new MessageUpdateEvent {Message = "Module1"});
      Thread.Sleep(2000); //simulate long loading of the module
      IModule customersModule = Container.Resolve<Module1.Module>();
      customersModule.Initialize();

      EventAggregator.GetEvent<MessageUpdateEvent>().Publish(new MessageUpdateEvent { Message = "Module2" });
      Thread.Sleep(2000); //simulate long loading of the module
      IModule locationModule = Container.Resolve<Module2.Module>();
      locationModule.Initialize();

      EventAggregator.GetEvent<MessageUpdateEvent>().Publish(new MessageUpdateEvent { Message = "Module3" });
      Thread.Sleep(2000); //simulate long loading of the module
      IModule ordersModule = Container.Resolve<Module3.Module>();
      ordersModule.Initialize();
    }
  }
Having trouble coming up with a solution. I have large amounts of data to load and need this logic. I tried using the code from this project "Improving perceived WPF app startup performance with MEF and a Splash Screen", but also having trouble getting imports to work.

Help would really be appreciated, Thanks!

New Post: Manually loading module using InitializeModules?...

$
0
0
I found my solution by using:
IModuleManager manager = ServiceLocator.Current.GetInstance<IModuleManager>();
manager.LoadModule("ModuleA");

New Post: solution works in test & debug but not on server - "Path cannot be the empty string or all whitespace"

$
0
0
I have a suite of components that are designed to be reused over quite a few large/small disparate developments/solutions. These all work fine in debug and integration test off server but when they are deployed to the test server environment we get strange and in the end unhelpful errors messages. We have had to go back into the code to increase the information we could get out of the system as the exceptions were originally pointing us to the dreaded "Loader Exceptions" collection and then the "CompositionException.Errors" exception.

Components stored each in their own directory - not in the exec folder/subfolder - they get pulled in to the Container by a bit of bootstrap code which uses absolute refs to each component's directory to create a DirectoryCatalog for each component which gets added to an AggregateCatalog.

In debug/testing this all works fine.

The server pumps out this message:

"The composition produced a single composition error. The root cause is provided below. Review the CompoistionException.Errors property for more detailed information.

1) Path cannot be the empty string or all whitespace.

Resulting in: An exception occurred while trying to create an instance of type 'email.sender'..."

It then goes on to list the subsequent fails because this "email.sender" failed.

We have taken this and all dependent modules and removed the directory ref bootstrapper bit and directly referenced the components and simply cataloged the BaseDirectory - with the same results - good in debug and bad on server.

Any clues please?

New Post: problem with load assembly

$
0
0
I have a problem with load assembly. I have two solutions. The first solution, which name is Studio want load and use second solution, which name is Worker. Type of Worker solution is class library. Worker solution use some outsider assemblys, which names is Ecng.Common, Ecng.Data, etc. . When i try to load Worker solution in Studio solution by MEF, MEF throw exception, that say, that he can't find file or assemble Ecng.Transactions. But this assembly don't using in Worker solution. Worker solution work without it. What i need to do? Sorry about my english, it is't very good.

New Post: Composing inter-dependant objects

$
0
0
Hi there,

I'm trying to introduce MEF and nHibernate into a legacy windows forms application. I've currently got a factory which exports nHibernates' ISession interface and I'm trying to work out how to get a single instantiation injected into a form AND it's custom controls.

E.g. I have a custom search control that is used on many forms. I've added an ISession import as a property (as ImportingConstructor will break the windows forms designer). This custom search control is part of a form that also has a ISession on it's ImportingConstructor. How can I get the same instance of ISession that is used to compose the form, also into the custom control?

Or am I barking up the wrong tree with the direction I'm taking?

New Post: Composing inter-dependant objects

$
0
0

hi mrsquish,

I am not very familiar with nhibernate, but the problem that you are running into would seem to be solvable by using the CompositionScopeDefinition class. At a high level . Composition Scope Definition allows you a mechanism to define scopes in which things are shared. Take a look at this article which talks about Composition Scope Definition and let us know if that works for you

http://blogs.msdn.com/b/bclteam/archive/2011/12/19/sharing-with-compositionscopedefinition-in-mef2-alok.aspx

cheers

New Post: Composing inter-dependant objects

$
0
0
Hi alokshriram,

Thanks so much for the reply. Sorry I should have described the full situation a little better. I'm currently constrained to .Net 4.0 as my customers platforms include XP machines. So I don't think I can use MEF2?

Cheers.

New Post: Composing inter-dependant objects

$
0
0
Hi alokshriram,

I've read up on the composition scope definition and it looks to be exactly what I'm after. Thank you for bringing it to my attention, now I just wish I could use it!

New Post: Composing inter-dependant objects

$
0
0

J. Hopefully the article gets you started. Let me know if you run into issues.

thanks

-alok

New Post: Composing inter-dependant objects

$
0
0
Hi Alok,

I'm pretty sure given my small amount of reading that I cannot use your solution as I'm constrained to .Net 4.0.

New Post: Composing inter-dependant objects

$
0
0

Fair.. Sorry I missed your earlier comment about you using .Net 4.0


New Post: Composing inter-dependant objects

$
0
0
For any of those that are interested, I ended up creating an interface IRequireSession which has the following declaration
    public interface IRequireSession
    {
        ISession Session { get; set; }
    }
And is implemented in a Form base class :
    public class DataForm : Form, IRequireSession
    {
        private ISession _session;

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        [Import()]
        public ISession Session
        {
            get { return _session; }
            set { 
                _session = value;
                SetSession(this.Controls);
            }
        }

        private void SetSession(Control.ControlCollection controls)
        {
            foreach (Control control in controls)
            {
                if (control is IRequireSession)
                    ((IRequireSession)control).Session = _session;
                SetSession(control.Controls);
            }
        }
    }
This means that I can derive my normal forms from DataForm and get the session passed through to any user controls that implement IRequireSession. Although, I've got a funny feeling that MEF doesn't support attributes on base classes. . I guess I'll find out soon enough.

New Post: MEF distributions

$
0
0
Hi,
I'm trying to organize all the different MEF distributions and the features that each has, it will be really nice if someone can help me with that.

From what I understand there is MEF in .NET 4.0 and 4.5.
There are alos out-of-band release from the source at this project site which are delivered using NuGet, the latest is 1.0.17.

It will be really nice to have a clear table of which .NET version support which MEF version and what features each MEF version has.
I have more questions in this matter but let's start from the basic.

Thank you,
Ido.

New Post: mefx for convention based composition

$
0
0
Hi,
Is there a plan to create mefx like tool for convention based composition ?

Thank you,
Ido.

New Post: mefx for convention based composition

$
0
0

Hi Ido,

As of right now the framework team does not have something like this on the radar. We will keep your request in mind for future planning.

thanks

-alok

Program Manager

.NET Ecosystem

New Post: MEF distributions

$
0
0

Ido,

For difference between Mef 4.0 and Mef 4.5 see this article . With regards to platforms that they support both work on the desktop.

The OOB release of MEF has the features as listed in the following article .

Hope this provides you a starting point.

thanks

-alok

Viewing all 265 articles
Browse latest View live


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