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

New Post: Two Singleton Instances

$
0
0
I am wondering if it is possible to have two singleton instances. I have a following scenario described below. I am looking for a way by which firstDeviceDriver and secondDeviceDriver are different instances however in different Algo files they behave as singletons, i.e secondDeviceDriver in both the algo files refer to the same instance.

I am also open on any tricks we can play to make it work ,except creating two devicedriver exports.

--------------------dll one --------------------
[Export]
public class DeviceDriverA
{
}
-------------------- dll two --------------------------
public class AlgoOne
{
  [Import(DeviceDriverA)]   
  public DeviceDriverA firstDeviceDriver {get;set;}

  [Import(DeviceDriverA)]   
  public DeviceDriverA secondDeviceDriver {get;set;}
}

-------------------- dll three --------------------------
public class AlgoTwo
{
  [Import(DeviceDriverA)]   
  public DeviceDriverA secondDeviceDriver {get;set;}
}

New Post: MEF 2.0 (Nuget version) is not compatible with .NET 4.5.2

$
0
0
If you try to create a ContainerConfiguration in .NET 4.5.2, you will likely get the following error message:

"The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'."

Please, upgrade the nuget package.

Updated Wiki: Home

$
0
0

Welcome to the MEF Community Site

Important: this site hosts source code for unsupported, pre-release versions of MEF. If you want to use MEF in production, you should strongly consider using the supported versions included in the .NET Framework and Silverlight.

.NET 4.5 and Windows 8 Store apps can now install the fully-supported, lightweight Microsoft.Composition package from NuGet.

What is it?

The Managed Extensibility Framework (MEF) is a composition layer for .NET that improves the flexibility, maintainability and testability of large applications. MEF can be used for third-party plugin extensibility, or it can bring the benefits of a loosely-coupled plugin-like architecture to regular applications.

Status

MEF is a part of the Microsoft .NET Framework, with types primarily under the System.ComponentModel.Composition.* namespaces. There are two versions of MEF
  • MEF has shipped with .NET 4.0 and higher and Silverlight 4. This provides the standard extension model that has been used in Visual Studio.
  • MEF 2 is a lightweight version of MEF, which has been optimized for static composition scenarios and provides faster compositions. It is also the only version of MEF that is as a portable class library and can be used on phone, store, desktop and web applications.
    • Windows 8 Store apps are supported via NuGet

Updated Wiki: Home

$
0
0

Welcome to the MEF Community Site

Important: this site hosts source code for unsupported, pre-release versions of MEF. If you want to use MEF in production, you should strongly consider using the supported versions included in the .NET Framework and Silverlight.

.NET 4.5 and Windows 8 Store apps can now install the fully-supported, lightweight Microsoft.Composition package from NuGet.

What is it?

The Managed Extensibility Framework (MEF) is a composition layer for .NET that improves the flexibility, maintainability and testability of large applications. MEF can be used for third-party plugin extensibility, or it can bring the benefits of a loosely-coupled plugin-like architecture to regular applications.

Status

MEF is a part of the Microsoft .NET Framework, with types primarily under the System.ComponentModel.Composition.* namespaces. There are two versions of MEF
  • MEF has shipped with .NET 4.0 and higher and Silverlight 4. This provides the standard extension model that has been used in Visual Studio.
  • MEF 2 is a lightweight version of MEF, which has been optimized for static composition scenarios and provides faster compositions. It is also the only version of MEF that is as a portable class library and can be used on phone, store, desktop and web applications. This version of MEF is available viaNuGet.

Updated Wiki: Home

$
0
0

Welcome to the MEF Community Site

Important: this site hosts source code for both
MEF which ships as the part of the .NET framework which ships in box and is not portable
the portable revision of MEF available on NuGet.

.NET 4.5 and Windows 8 Store apps can now install the fully-supported, lightweight Microsoft.Composition package from NuGet.

What is it?

The Managed Extensibility Framework (MEF) is a composition layer for .NET that improves the flexibility, maintainability and testability of large applications. MEF can be used for third-party plugin extensibility, or it can bring the benefits of a loosely-coupled plugin-like architecture to regular applications.

Status

MEF is a part of the Microsoft .NET Framework, with types primarily under the System.ComponentModel.Composition.* namespaces. There are two versions of MEF
  • MEF has shipped with .NET 4.0 and higher and Silverlight 4. This provides the standard extension model that has been used in Visual Studio.
  • MEF 2 is a lightweight version of MEF, which has been optimized for static composition scenarios and provides faster compositions. It is also the only version of MEF that is as a portable class library and can be used on phone, store, desktop and web applications. This version of MEF is available viaNuGet.

Updated Wiki: Home

$
0
0

Welcome to the MEF Community Site

Important: this site hosts source code for both
MEF which ships as the part of the .NET framework which ships in box and is not portable
the portable revision of MEF available on NuGet.

.NET 4.5 and Windows 8 Store apps can now install the fully-supported, lightweight Microsoft.Composition package from NuGet.

What is it?

The Managed Extensibility Framework (MEF) is a composition layer for .NET that improves the flexibility, maintainability and testability of large applications. MEF can be used for third-party plugin extensibility, or it can bring the benefits of a loosely-coupled plugin-like architecture to regular applications.

Status

MEF is a part of the Microsoft .NET Framework, with types primarily under the System.ComponentModel.Composition.* namespaces. There are two versions of MEF
  • MEF has shipped with .NET 4.0 and higher and Silverlight 4. This provides the standard extension model that has been used in Visual Studio.
  • MEF 2 is a lightweight version of MEF, which has been optimized for static composition scenarios and provides faster compositions. It is also the only version of MEF that is as a portable class library and can be used on phone, store, desktop and web applications. This version of MEF is available via NuGet.

Updated Wiki: Home

$
0
0

Welcome to the MEF Community Site

Important: this site hosts source code for both
MEF which ships as the part of the .NET framework which ships in box and is not portable
the portable revision of MEF available on NuGet.

.NET 4.5 and Windows 8 Store apps can now install the fully-supported, lightweight Microsoft.Composition package from NuGet.

What is it?

The Managed Extensibility Framework (MEF) is a composition layer for .NET that improves the flexibility, maintainability and testability of large applications. MEF can be used for third-party plugin extensibility, or it can bring the benefits of a loosely-coupled plugin-like architecture to regular applications.

Status

MEF is a part of the Microsoft .NET Framework, with types primarily under the System..Composition. namespaces. There are two versions of MEF

Updated Wiki: Home

$
0
0

Welcome to the MEF Community Site

Important: this site hosts source code for both
MEF which ships as the part of the .NET framework which ships in box and is not portable
the portable revision of MEF available on NuGet.

.NET 4.5 and Windows 8 Store apps can now install the fully-supported, lightweight Microsoft.Composition package from NuGet.

What is it?

The Managed Extensibility Framework (MEF) is a composition layer for .NET that improves the flexibility, maintainability and testability of large applications. MEF can be used for third-party plugin extensibility, or it can bring the benefits of a loosely-coupled plugin-like architecture to regular applications.

Status

MEF is a part of the Microsoft .NET Framework, with types primarily under the System..Composition. namespaces. There are two versions of MEF

Updated Wiki: Home

$
0
0

Welcome to the MEF Community Site

Important: this site hosts source code for both
MEF which ships as the part of the .NET framework which ships in box and is not portable
the portable revision of MEF available on NuGet.

.NET 4.5 and Windows 8 Store apps can now install the fully-supported, lightweight Microsoft.Composition package from NuGet.

What is it?

The Managed Extensibility Framework (MEF) is a composition layer for .NET that improves the flexibility, maintainability and testability of large applications. MEF can be used for third-party plugin extensibility, or it can bring the benefits of a loosely-coupled plugin-like architecture to regular applications.

Status

MEF is a part of the Microsoft .NET Framework, with types primarily under the System..Composition. namespaces. There are two versions of MEF
  • System.ComponentModel.Composition.* which has shipped with .NET 4.0 and higher and Silverlight 4. This provides the standard extension model that has been used in Visual Studio. This documentation for this version of MEF can be found herehttp://msdn.microsoft.com/en-us/library/system.componentmodel.composition(v=vs.110).aspx
  • System.Compostion.*_ is a lightweight version of MEF, which has been optimized for static composition scenarios and provides faster compositions. It is also the only version of MEF that is as a portable class library and can be used on phone, store, desktop and web applications. This version of MEF is available via NuGet and is documentation is available here

Updated Wiki: Home

$
0
0

Welcome to the MEF Community Site

Important: this site hosts source code for both
MEF which ships as the part of the .NET framework which ships in box and is not portable
the portable revision of MEF available on NuGet.

.NET 4.5 and Windows 8 Store apps can now install the fully-supported, lightweight Microsoft.Composition package from NuGet.

What is it?

The Managed Extensibility Framework (MEF) is a composition layer for .NET that improves the flexibility, maintainability and testability of large applications. MEF can be used for third-party plugin extensibility, or it can bring the benefits of a loosely-coupled plugin-like architecture to regular applications.

Status

MEF is a part of the Microsoft .NET Framework, with types primarily under the System..Composition. namespaces. There are two versions of MEF
  • System.ComponentModel.Composition.* which has shipped with .NET 4.0 and higher and Silverlight 4. This provides the standard extension model that has been used in Visual Studio. This documentation for this version of MEF can be found here
  • System.Compostion.*_ is a lightweight version of MEF, which has been optimized for static composition scenarios and provides faster compositions. It is also the only version of MEF that is as a portable class library and can be used on phone, store, desktop and web applications. This version of MEF is available via NuGet and is documentation is available here

Updated Wiki: Home

$
0
0

Welcome to the MEF Community Site

Important: this site hosts source code for both
MEF which ships as the part of the .NET framework which ships in box and is not portable
the portable revision of MEF available on NuGet.

.NET 4.5 and Windows 8 Store apps can now install the fully-supported, lightweight Microsoft.Composition package from NuGet.

What is it?

The Managed Extensibility Framework (MEF) is a composition layer for .NET that improves the flexibility, maintainability and testability of large applications. MEF can be used for third-party plugin extensibility, or it can bring the benefits of a loosely-coupled plugin-like architecture to regular applications.

Status

MEF is a part of the Microsoft .NET Framework, with types primarily under the System..Composition. namespaces. There are two versions of MEF
  • System.ComponentModel.Composition.* which has shipped with .NET 4.0 and higher and Silverlight 4. This provides the standard extension model that has been used in Visual Studio. The documentation for this version of MEF can be found here
  • System.Compostion.*_ is a lightweight version of MEF, which has been optimized for static composition scenarios and provides faster compositions. It is also the only version of MEF that is as a portable class library and can be used on phone, store, desktop and web applications. This version of MEF is available via NuGet and is documentation is available here

New Post: Understanding MEF

$
0
0
I just want to understand MEF in a comparison with the old plug-in style I have been using on a project.
I use source code written in C# or Visual Basic. When the application starts, it looks in the plugin folder and compiles the code into an appdomain (In memory dll). There is a plugin base that plugins inherit.
One of the problems of using that method is that when plugins are disabled, it disables the functionality, but does not remove it from the in memory dll. Also, when adding a new extension, the application has to be restarted so it can compile the source code again.

I am looking into switching to MEF, but I have a few questions.
  1. How does it discover plugins?
  2. Can It detect source code and compile it?
  3. Can I truly disable or unload a specific extension so that it is no longer in memory?
  4. Can I use event handlers from custom events that are in the business logic?
Thank you.

New Post: Loading satellite assemblies

$
0
0
Any updates on this question please? I've run into same problem. Using AppDomain.ResolveAssembly event do the job, but is it desired behaviour? Doesn't MEF handle it itself?

Commented Unassigned: AtomicComposition encountered an unexpected Exception [14613]

$
0
0
Getting the following error occasionally


ProcessEntry() failed. InvalidOperationException: AtomicComposition encountered an unexpected Exception, review InnerException for details.
Stack Trace:
at System.ComponentModel.Composition.Hosting.AtomicComposition.FinalComplete()
at System.ComponentModel.Composition.Hosting.AtomicComposition.Complete()
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.DetermineRejection(ComposablePartDefinition definition, AtomicComposition parentAtomicComposition)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.IsRejected(ComposablePartDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InternalGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InnerCatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportsCore(Type type, Type metadataViewType, String contractName, ImportCardinality cardinality)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValueCore[T](String contractName, ImportCardinality cardinality)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValue[T](String contractName)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValue[T]()

--------------------------Inner Exception--------------------------
AggregateException: One or more errors occurred.

NullReferenceException: Object reference not set to an instance of an object.
Stack Trace:
at Microsoft.Internal.Collections.WeakReferenceCollection`1.<CleanupDeadReferences>b__0(WeakReference w)
at System.Collections.Generic.List`1.RemoveAll(Predicate`1 match)
at Microsoft.Internal.Collections.WeakReferenceCollection`1.CleanupDeadReferences()
at Microsoft.Internal.Collections.WeakReferenceCollection`1.Add(T item)
at System.ComponentModel.Composition.Hosting.ImportEngine.StartSatisfyingImports(PartManager partManager, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ImportEngine.EngineContext.Complete()
at System.ComponentModel.Composition.Hosting.AtomicComposition.FinalComplete()

Comments: I've seen the inner exception as well. I have no idea where this may come from. Any hints from the team? ``` System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Internal.Collections.WeakReferenceCollection`1.<CleanupDeadReferences>b__0(WeakReference w) at System.Collections.Generic.List`1.RemoveAll(Predicate`1 match) at Microsoft.Internal.Collections.WeakReferenceCollection`1.Add(T item) at System.ComponentModel.Composition.Hosting.ImportEngine.StartSatisfyingImports(PartManager partManager, AtomicComposition atomicComposition) at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager, ComposablePart part, Boolean shouldTrackImports) at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImports(ComposablePart part) at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition) at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(CatalogPart part, ExportDefinition export, Boolean isSharedPart) at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export) at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValueCore[T](String contractName, ImportCardinality cardinality) at my code ```

New Post: Loading satellite assemblies

$
0
0
[Pitchblack,Rabbit89]
Couple of questions.
1) I presume you are using the version of MEF in .NET .4.5.1 not the Nuget package? Correct me if am wrong.
2) Could either of you send me a description of your composition graph ?
thanks
-alok

Created Unassigned: Open generics with type constraints and RegisterationBuilder [14618]

$
0
0
When creating an AssemblyCatalog and passing RegistrationBuilder, open generics where the generic interface has type constraints, stop working. See http://stackoverflow.com/q/24590096/782185

Commented Unassigned: AtomicComposition encountered an unexpected Exception [14613]

$
0
0
Getting the following error occasionally


ProcessEntry() failed. InvalidOperationException: AtomicComposition encountered an unexpected Exception, review InnerException for details.
Stack Trace:
at System.ComponentModel.Composition.Hosting.AtomicComposition.FinalComplete()
at System.ComponentModel.Composition.Hosting.AtomicComposition.Complete()
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.DetermineRejection(ComposablePartDefinition definition, AtomicComposition parentAtomicComposition)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.IsRejected(ComposablePartDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InternalGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InnerCatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportsCore(Type type, Type metadataViewType, String contractName, ImportCardinality cardinality)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValueCore[T](String contractName, ImportCardinality cardinality)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValue[T](String contractName)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValue[T]()

--------------------------Inner Exception--------------------------
AggregateException: One or more errors occurred.

NullReferenceException: Object reference not set to an instance of an object.
Stack Trace:
at Microsoft.Internal.Collections.WeakReferenceCollection`1.<CleanupDeadReferences>b__0(WeakReference w)
at System.Collections.Generic.List`1.RemoveAll(Predicate`1 match)
at Microsoft.Internal.Collections.WeakReferenceCollection`1.CleanupDeadReferences()
at Microsoft.Internal.Collections.WeakReferenceCollection`1.Add(T item)
at System.ComponentModel.Composition.Hosting.ImportEngine.StartSatisfyingImports(PartManager partManager, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ImportEngine.EngineContext.Complete()
at System.ComponentModel.Composition.Hosting.AtomicComposition.FinalComplete()

Comments: I also sometimes experiment this issue and have no clue what the problem can be. So far I get it while trying to access GetExportedValue<T> of a service exported as NonShared. What does the cleanup of dead reference has to do there ? :| Any help is welcome.

Commented Unassigned: AtomicComposition encountered an unexpected Exception [14613]

$
0
0
Getting the following error occasionally


ProcessEntry() failed. InvalidOperationException: AtomicComposition encountered an unexpected Exception, review InnerException for details.
Stack Trace:
at System.ComponentModel.Composition.Hosting.AtomicComposition.FinalComplete()
at System.ComponentModel.Composition.Hosting.AtomicComposition.Complete()
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.DetermineRejection(ComposablePartDefinition definition, AtomicComposition parentAtomicComposition)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.IsRejected(ComposablePartDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InternalGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InnerCatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportsCore(Type type, Type metadataViewType, String contractName, ImportCardinality cardinality)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValueCore[T](String contractName, ImportCardinality cardinality)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValue[T](String contractName)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValue[T]()

--------------------------Inner Exception--------------------------
AggregateException: One or more errors occurred.

NullReferenceException: Object reference not set to an instance of an object.
Stack Trace:
at Microsoft.Internal.Collections.WeakReferenceCollection`1.<CleanupDeadReferences>b__0(WeakReference w)
at System.Collections.Generic.List`1.RemoveAll(Predicate`1 match)
at Microsoft.Internal.Collections.WeakReferenceCollection`1.CleanupDeadReferences()
at Microsoft.Internal.Collections.WeakReferenceCollection`1.Add(T item)
at System.ComponentModel.Composition.Hosting.ImportEngine.StartSatisfyingImports(PartManager partManager, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ImportEngine.EngineContext.Complete()
at System.ComponentModel.Composition.Hosting.AtomicComposition.FinalComplete()

Comments: Hi I think my case it seems the error was related to a bad use of MEF in a multi thread environment. MEF isn't thread safe and this is what did cause those exception when GetExportedValue was called in the same time by 2 diff threads.. http://blogs.microsoft.co.il/bnaya/2010/12/04/dynamic-mef-isnt-thread-safe-by-nature/ http://blogs.microsoft.co.il/zuker/2011/01/02/mef-thread-safety-and-getexportedvalue/ I just had to add (isThreadSafe = true) to the CompositionContainer constructor. hope it helps.

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

$
0
0
Rated 5 Stars (out of 5) - 太难找到下载的方法了,非要回复,真神勇

New Post: Associate a specific instance with an export

$
0
0
I'm attempting to move to MEF 2 and having trouble with some of the analogs. In MEF, you could compose a type and add it to the dictionary using a CompositionBatch like so:
    // Add the shared RootURI of the main page of the application to the composition container.
    CompositionBatch compositionBatch = new CompositionBatch();
    compositionBatch.AddExportedValue<Uri>("RootUri", new Uri(@"pack://application:,,,/Teraque.LicenseManager.License;/Teraque.LicenseManager.FrameView"));
    this.Container.Compose(compositionBatch);
This could then be referenced by getting:
    Uri uri = compositionContainer.GetExportedValue<Uri>("RootUri");
How do add a pre-constructed value into the composition container so it can be referenced in MEF 2? That is, what is the corresponding operation?
Viewing all 265 articles
Browse latest View live


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