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

New Post: Importing Multiple InheritedExport Interfaces

$
0
0

jpatrick62,

you need to apply the import attributes over each property as below. Two imports on the same property will not work as the composition engine will not know which import it should use to satisfy a property. If there are multiple Exports that can satisfy an import use the ImportMany attribute.

        [Import(typeof(Object1), AllowRecomposition = true)]
        private Object1 _obj1;
        [Import(typeof(Object2), AllowRecomposition = true)]
        private Object2  _obj2;

cheers

-alok


Reviewed: MEF Analysis Tool (mefx) for .NET 4.0 Beta (十二月 16, 2014)

$
0
0
Rated 4 Stars (out of 5) - oh,my god,it's so hard

Reviewed: MEF Analysis Tool (mefx) for .NET 4.0 Beta (十二月 23, 2014)

$
0
0
Rated 4 Stars (out of 5) - 只有回复以后才可以下载吗?

New Post: A question about class CompositionContainer

$
0
0
I added a new an instance of CompositionContainer named C2 for a program which has been using an instance of CompositionContainer named C1. I found there are no any import classes within C2, while both they are within C1. So I've a confusion for class CompositionContainer, is there only one instance usefull within a program?

Created Unassigned: MEF should allow metadata view types with constructors of IReadOnlyDictionary [14621]

$
0
0
If you create a metadata view type, the constructor of the type must accept an IDictionary<string, object>. This means you can't use an IReadOnlyDictionary<string, object> which is a separate (and more appropriate) interface. MEF should allow use of the other interface and correctly invoke the constructor.

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

$
0
0
There's much confusion regarding the DirectoryCatalog that can't be referenced from System.ComponentModel.Composition in VNext ASP.NET projects. It's just a case of different method of doing the same thing:

using System.IO;
using System.Composition;
using System.Composition.Hosting;
using System.Reflection;
    public class Imports
    {
        [ImportMany]
        public IEnumerable<Lazy<IPlugin>> Plugins { get; set; }

        public Imports()
        {
            var configuration = new ContainerConfiguration()
                   .WithAssembly(typeof(IPlugin).GetTypeInfo().Assembly);

            var compositionHost = configuration.CreateContainer();         
            compositionHost.SatisfyImports(this);                                          
        }                

        public Imports(string pluginPath, string searchPattern)
        {
            var dirCat = new List<Assembly>();
            var dirInfo = new DirectoryInfo(pluginPath);
            var dirDlls = dirInfo.GetFiles(searchPattern, SearchOption.TopDirectoryOnly);
            foreach (var fileInfo in dirDlls)
            {
                var dllPath = fileInfo.FullName;
                var newAssembly = Assembly.Load(System.IO.File.ReadAllBytes(dllPath));
                dirCat.Add(newAssembly);
            }
            var configuration = new ContainerConfiguration()
                   .WithAssemblies(dirCat);
            var compositionHost = configuration.CreateContainer();
            compositionHost.SatisfyImports(this);
        }
    }

   static void Main(string[] args)
    {

        Console.WriteLine("START ===>");
        var dirPath = @"C:\jedev\ConsoleApplication1\ConsoleApplication1\bin\Debug";
        var i = new Imports(dirPath, "*.dll");
        foreach( var p in i.Plugins)
        {
            Console.WriteLine(p.Value.PluginName);
        }

        Console.WriteLine("END ===>");
        Console.ReadLine();
    }

New Post: Using MEF with recursion and TreeView

$
0
0
I have an application where I'd like to display a list of all plugins located in a specified directory (and sub-directories). This is my first time using MEF and so I'm having some difficulty understanding how the framework works and in what order things need to be done. I think I know what the problem is (more later), but I'm not sure and I'm uncertain in how to fix it.
    private CompositionContainer container;
    
    private AggregateCatalog catalog = new AggregateCatalog();
    
    [ImportMany(typeof(IPlugin), AllowRecomposition = true)]
    IEnumerable<Lazy<IPlugin, IPluginData>> plugins = null;
    
    private void LoadPlugins(string rootPath)
    {
        /* release old contents if the refreshTree 
         * method is called
         */
        if (null != plugins)
            container.ReleaseExports(plugins);
    
        try
        {
            TreeNode rootNode = new TreeNode(rootPath);
            rootNode.Name = rootPath;
            
            populateTreeView(rootNode.Nodes, rootNode, true);
            
            // add the root node to the TreeView
            pluginTreeView.Nodes.Add(rootNode);
    
            container = new CompositionContainer(catalog);
            container.ComposeParts(this);
        }
        catch (CompositionException ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
    
    private bool appendToCatalog(string path, bool create, out DirectoryCatalog dirCatalog)
    {
        dirCatalog = null;
        // check that the plugin directory exists
        if (false == System.IO.Directory.Exists(path))
        {
            // do we want to create a directory for it?
            if(true == create) 
                System.IO.Directory.CreateDirectory(path);
            return false;
        }
        // finally, append the plugins to the catalog
        dirCatalog = new DirectoryCatalog(path, Constants.Strings.PLUGIN_EXTENSION);
        catalog.Catalogs.Add(dirCatalog);
        return true;
    }
    
    private void populateTreeView(TreeNodeCollection nodes, TreeNode currentNode, bool isRoot)
    {
        DirectoryCatalog dirCatalog;
    
        if(false == appendToCatalog(currentNode.Name, isRoot, out dirCatalog))
            return;
        
        try
        {
            // get subfolder list
            string[] directories = Directory.GetDirectories(currentNode.Name);
    
            //add a new node for each subfolder
            foreach (string directory in directories)
            {
                nodes.Add(directory, Path.GetFileName(directory));
            }
            
            // Problem is probably here
            foreach (var plugin in plugins)
            {
                nodes.Add(plugin.Metadata.Name, plugin.Metadata.Name);
            }
    
            foreach(TreeNode node in nodes)
                populateTreeView(node.Nodes, node, false);
        }
        catch
        {
            return;
        }
    }
Now, here's what I believe the problem is. If you notice in the populateTreeView() function I have the following comment: // Problem is probably here. My assumption here is that the plugins have not yet been loaded and therefore the foreach loop is never executed. But at the same time, I'd like to only load valid plugins (i.e. No dll's from another unrelated project), so I'd rather not display a list of all dll's in the folder.

Created Unassigned: OnImportsSatisfied called in the wrong order [14622]

$
0
0
In the basic scenario in which part A has a dependency on part B, and both part A and part B have methods with [OnImportsSatisfied] attributes, the method in part A is called before that in part B. This is completely wrong as part A's imports aren't satisfied until part B is ready. And until part B's [OnImportsSatisfied] method is called, it isn't ready. The older version of MEF (System.ComponentModel.Composition) included with Visual Studio handles this correctly on the other hand.

Repro:
http://pastebin.com/SVFUJ2zN

Expected behaviour
From C (as C has no dependencies)
From B (as C, B's only dependency, is now resolved)
From A (as B, A's only dependency, is now resolved)

Actual behaviour:
From A (wrong as B has not yet resolved)
From B (wrong as C has not yet resolved)
From C

Commented Unassigned: OnImportsSatisfied called in the wrong order [14622]

$
0
0
In the basic scenario in which part A has a dependency on part B, and both part A and part B have methods with [OnImportsSatisfied] attributes, the method in part A is called before that in part B. This is completely wrong as part A's imports aren't satisfied until part B is ready. And until part B's [OnImportsSatisfied] method is called, it isn't ready. The older version of MEF (System.ComponentModel.Composition) included with Visual Studio handles this correctly on the other hand.

Repro:
http://pastebin.com/SVFUJ2zN

Expected behaviour
From C (as C has no dependencies)
From B (as C, B's only dependency, is now resolved)
From A (as B, A's only dependency, is now resolved)

Actual behaviour:
From A (wrong as B has not yet resolved)
From B (wrong as C has not yet resolved)
From C
Comments: This breaks in many real-world scenarios. If, for instance, an import for a graphics context sets up managed resources ready for other components to use in its OnImportsSatisfied method, and another component loads content using that context in its OnImportsSatisfied method, the component trying to load content initializes first, before the graphics context has initialized.

New Post: Make sure that the controller has a parameterless public constructor

$
0
0
I use MEF, WebAPI in VS 2012.

I get error
__
.","exceptionMessage":"An error occurred when trying to create a controller of type 'ClienteController'. Make sure that the controller has a parameterless public constructor.","exceptionType":"System.InvalidOperationException","__

I have in Global.asax.cs:
public class WebApiApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        GlobalConfiguration.Configure(WebApiConfig.Register);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);

        AggregateCatalog catalog = new AggregateCatalog();
        catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
        CompositionContainer container = MEFLoader.Init(catalog.Catalogs);
        DependencyResolver.SetResolver(new MefDependencyResolver(container)); // view controllers
        GlobalConfiguration.Configuration.DependencyResolver = new MefAPIDependencyResolver(container); // web api controllers

    }

In my MEFLoader class
    public static CompositionContainer Init(ICollection<ComposablePartCatalog> catalogParts)
    {
        var catalog = new AggregateCatalog();

        catalog.Catalogs.Add(new AssemblyCatalog(typeof(BuscadorClient).Assembly));
        catalog.Catalogs.Add(new AssemblyCatalog(typeof(Core.DataRepositoryFactory).Assembly));
        catalog.Catalogs.Add(new AssemblyCatalog(typeof(Comun.DataContract.BusinessFault).Assembly));

        if (catalogParts != null)
            foreach (var part in catalogParts)
                catalog.Catalogs.Add(part);

        var container = new CompositionContainer(catalog);
        return container;
    }
Assemblies has in the bin folder of the website for the Webapi Application, in the Integration environment .

Notes:

In Development environment, dev local, sometimes failed and solution was "recompile" the WebApi App Project (csproj)

Anyways, in Integration environment failed.
Microsoft.Internal.Collections.WeakReferenceCollection1.<CleanupDeadReferences>b__0(WeakReference w)\r\n at System.Collections.Generic.List1.RemoveAll(Predicate1 match)\r\n at Microsoft.Internal.Collections.WeakReferenceCollection1.Add(T item)\r\n at System.ComponentModel.Composition.Hosting.ImportEngine.StartSatisfyingImports(PartManager partManager, AtomicComposition atomicComposition)\r\n at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager, ComposablePart part, Boolean shouldTrackImports)\r\n at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImports(ComposablePart part)\r\n at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition)\r\n at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(CatalogPart part, ExportDefinition export, Boolean isSharedPart)\r\n at System.ComponentModel.Composition.Primitives.Export.get_Value()\r\n at System.ComponentModel.Composition.ReflectionModel.ImportingItem.CastSingleExportToImportType(Type type, Export export)\r\n at System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.SetImport(ImportingItem item, Export[] exports)\r\n at System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.SetImport(ImportDefinition definition, IEnumerable1 exports)\r\n at System.ComponentModel.Composition.Hosting.ImportEngine.PartManager.TrySetImport(ImportDefinition import, Export[] exports)\r\n at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset(PartManager partManager, IEnumerable1 imports, AtomicComposition atomicComposition)\r\n at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportsStateMachine(PartManager partManager, ComposablePart part)\r\n at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager, ComposablePart part, Boolean shouldTrackImports)\r\n at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImports(ComposablePart part)\r\n at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition)\r\n at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(CatalogPart part, ExportDefinition export, Boolean isSharedPart)\r\n at System.ComponentModel.Composition.Primitives.Export.get_Value()\r\n at COMPANY..Core.MefExtensions.GetExportedValueByType(CompositionContainer container, Type type) in

New Comment on "Sharing and lifetime"

$
0
0
Limited or no documentation on Lifetime, though the heading includes Lifetime.

New Post: Must I use ExportFactory when using CompositionScopeDefinition ?

$
0
0
Hi,

Must I use ExportFactory when using CompositionScopeDefinition ?

All the sample I found use ExportFactory ,at least for the root object

thanks in advance

New Comment on "Exports and Metadata"

$
0
0
Is Metadata handling different in MEF2? When I try to SatisfyImports, this example gives me: System.Composition.Hosting.CompositionFailedException was unhandled HResult=-2146233088 Message=The type 'IMessageSenderCapabilities' cannot be used as a metadata view. A metadata view must be a concrete class with a parameterless or dictionary constructor. Source=System.Composition.Hosting StackTrace: at System.Composition.Hosting.Providers.Metadata.MetadataViewProvider.GetMetadataViewProvider[TMetadata]() at System.Composition.Hosting.Providers.Lazy.LazyWithMetadataExportDescriptorProvider.GetLazyDefinitions[TValue,TMetadata](CompositionContract lazyContract, DependencyAccessor definitionAccessor) at System.Composition.Hosting.Providers.Lazy.LazyWithMetadataExportDescriptorProvider.GetExportDescriptors(CompositionContract exportKey, DependencyAccessor definitionAccessor) at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.GetPromises(CompositionContract contract) at System.Composition.Hosting.Core.DependencyAccessor.ResolveDependencies(Object site, CompositionContract contract, Boolean isPrerequisite) at System.Composition.Hosting.Providers.ImportMany.ImportManyExportDescriptorProvider.<>c__DisplayClass5`1.<GetImportManyDescriptor>b__0() at System.Composition.Hosting.Core.ExportDescriptorPromise.<>c__DisplayClass4.<.ctor>b__0() at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at System.Lazy`1.get_Value() at System.Composition.Hosting.Core.ExportDescriptorPromise.get_Dependencies() at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.CheckTarget(CompositionDependency dependency, HashSet`1 checked, Stack`1 checking) at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.Execute(CompositionContract contract) at System.Composition.Hosting.Core.ExportDescriptorRegistry.TryGetSingleForExport(CompositionContract exportKey, ExportDescriptor& defaultForExport) at System.Composition.Hosting.Core.LifetimeContext.TryGetExport(CompositionContract contract, Object& export) at System.Composition.Hosting.CompositionHost.TryGetExport(CompositionContract contract, Object& export) at System.Composition.CompositionContextExtensions.SatisfyImportsInternal(CompositionContext exportProvider, Object objectWithLooseImports, AttributedModelProvider conventions) at System.Composition.CompositionContextExtensions.SatisfyImports(CompositionContext compositionContext, Object objectWithLooseImports) at meftest.HttpServerHealthMonitor..ctor() in d:\Temp\Projects\meftest\meftest\IMessageSender.cs:line 22 at ConsoleApplication1.Program.Main(String[] args) in d:\Temp\Projects\meftest\ConsoleApplication1\Program.cs:line 14 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

New Post: Multi-threading issue when using MEF with WCF

$
0
0
Can you leave the answer for this problem Martin? I have the same problem too, isThreadSafe=true can't solve this problem.

New Post: Using MEF with recursion and TreeView

$
0
0
Not sure if you figured it out for yourself, but I posted an idea on my blog which I'll share here. It's in VB though.
'Create our Catalog of different Catalogs
        Dim catalog = New AggregateCatalog()

        'Add in any plugins that are in our own assembly
        catalog.Catalogs.Add(New AssemblyCatalog(GetType(Main).Assembly))
        
        'Check to see if our directory for our Plugins exists, if so add it as well
        If Directory.Exists("addons") Then catalog.Catalogs.Add(New DirectoryCatalog("addons", "*.dll"))
        
        'If we have any saved Locations outside of the main base locations (I use this in my project)
        If My.Settings.AddonLocations.Count > 0 Then
            For Each addloc In My.Settings.AddonLocations
                If System.IO.Directory.Exists(addloc.ToString) Then
                    'Add those as well
                    catalog.Catalogs.Add(New DirectoryCatalog(addloc, "*.dll"))
                End If
            Next
        End If

        'Create the CompositionContainer with the parts in the catalog
        _container = New CompositionContainer(catalog)

        'Fill the imports of this object
        Try
            _container.ComposeParts(Me)

           'If that was successful, then we know everything loaded, let's grab the filenames
            For Each cat In catalog.Catalogs
                'Check to make sure that the Catalog is a Directory Catalog (There are multiple TYPES)
                If TypeOf cat Is DirectoryCatalog Then
                    'Let's create a DirectoryCatalog and merge it with the contents of the current Catalog
                    Dim catdir As DirectoryCatalog = cat
                    'If the file loaded correctly then continue
                    If catdir.LoadedFiles.Count > 0 Then
                        'Grab each file individually
                        For Each lf In ids.LoadedFiles
                            'MessageBox the result for us to see....do what you will with it though
                            MsgBox(lf.ToString)
                        'Loop Back Through Each DLL
                        Next
                    End If
                Else 'Wasnot a Directory Catalog. The only other Catalog we coded for was an Assembly
                    Dim asm As AssemblyCatalog = i
                    'Again lets message out that location as well.
                    MsgBox(asm.Assembly.Location)
                End If
          'Loop back through again  
          Next
        Catch ref As ReflectionTypeLoadException
            For Each ex In ref.LoaderExceptions
                MsgBox(ex.Message)
            Next
        End Try
So basically, grab your AggregateCatalog that you created ("catalog" object in my code),
then do a For Each loop on the Catalogs subobject (catalog.Catalogs)
foreach ( void cat in catalog.Catalogs){

}
Then check what kind of Catalog you have, as they have different properties
if (cat is DirectoryCatalog) {
        DirectoryCatalog catdir = cat;
        if (catdir.LoadedFiles.Count > 0) {
            foreach (void filename in ids.LoadedFiles) {
                Interaction.MsgBox(filename.ToString);  //DirectoryCatalog . LoadedFiles ( index# )  will return the Full Path / Filename of the Loaded .dll from directories. 
            }
        }
    } else {
        AssemblyCatalog asm = cat;
        Interaction.MsgBox(asm.Assembly.Location); // AssemblyCatalog . Assembly . Location will produce a string for the full Path/Filename of the loaded Assembly
    }
Hope that helps, sorry if the C# is wrong in any way, I am more of a vb.net programmer than C#.
Cheers

Created Unassigned: Moq Unit testing using MEF Container [14623]

$
0
0
Hi All,

In our WPF MVVM Application , we are using MEF to create the instances of class.

We are using Moq Framework to perform unit testing for our classes, we have added the parts to Container and this will be used in our pathways whenever a instance is created.

In few instances where a type is created multiple times in our workflows we see same instance is retrieved each time from container, also our container is static in our application.

Please pour in your ideas how you have performed Unit testing for MEF+ MVVM applcations using Moq or any other frameworks.

Thanks,
Nagamani






Reviewed: MEF Analysis Tool (mefx) for .NET 4.0 Beta (五月 28, 2015)

$
0
0
Rated 5 Stars (out of 5) - Find is so easy!

Reviewed: MEF Preview 8 (六月 16, 2015)

$
0
0
Rated 2 Stars (out of 5) - jjjyhfhdfghdgdf

New Post: CompositionHosts exports run in parallel sometimes inject null to imported value

$
0
0
Hello,

I am working on a multi-tenant application, where every tenant has its own CompositionHost (System.Composition.Hosting.CompositionHost) with the same part types. When I try to get export of the same type from two CompositionHosts at the same time (in parallel), one of them will inject null into ImportingConstructor (or imported property as well).

Just to clarify - I am not using the same container in multiple threads. There are many CompositionHosts and every parallel export uses a different one.

The problem happens only on the first export of given type. It does not occur when exports are done sequentially.

Below I attach minimal code that reproduces my issue. Please bear in mind that due to parallel execution the issue may not always reproduce. Is there something wrong with the way I use CompositionHosts or is it a bug in MEF2?
  [Export]
    public class InjectedClass {}

    [Export]
    public class TestA
    {
        [ImportingConstructor]
        public TestA(InjectedClass injectedInstance)
        {
            if (injectedInstance == null)
                throw new ArgumentNullException("injectedInstance");
        }
    }

    class Program
    {
        static void Main()
        {
            const int containersCount = 2;
            var compositionContainers = Enumerable.Range(0, containersCount).Select(_ => InitContainer()).ToList();
            Parallel.ForEach(compositionContainers, cc => cc.GetExport<TestA>());
        }

        private static CompositionHost InitContainer()
        {
            var containerConfiguration = new ContainerConfiguration();
            containerConfiguration.WithPart<InjectedClass>();
            containerConfiguration.WithPart<TestA>();
            return containerConfiguration.CreateContainer();
        }
    }

Created Unassigned: Problem deploying Silverlight App using MEF and Azure [14624]

$
0
0
Hello I developed an app using Silverlight 5.

When I run this application in my computer this app works like a charm.
but When I publish this application to my WebRole in Azure my app is dead.

I was trying to figure what is going on. My enviroment is:

ASP.NET MVC 5
Silverlight 5 using MEF

I catched this error using Firebug

Error: Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.FieldAccessException: Error al intentar el método 'System.ComponentModel.Composition.ReflectionModel.ReflectionField.SetValue(System.Object, System.Object)' obtener acceso al campo 'SiivasaAppClient.ViewModels.ShellViewModel.mainView'.
at System.Reflection.RtFieldInfo.PerformVisibilityCheckOnField(IntPtr field, Object target, RuntimeType declaringType, FieldAttributes attr, UInt32 invocationFlags)
at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck, Boolean doCheckConsistency)
at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck)
at System.Reflection.RtFieldInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
at System.ComponentModel.Composition.ReflectionModel.ReflectionField.SetValue(Object instance, Object value)
at System.ComponentModel.Composition.ReflectionModel.ImportingMember.SetSingleMemberValue(Object instance, Object value)
at System.ComponentModel.Composition.ReflectionModel.ImportingMember.SetExportedValue(Object instance, Object value)
at System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.SetExportedValueForImport(ImportingItem import, ImportDefinition definition, Object value)
at System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.UseImportedValues[TImportDefinition](IEnumerable`1 definitions, Action`3 useImportValue, Boolean errorIfMissing)
at System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.SetNonPrerequisiteImports()
at System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.Activate()
at System.ComponentModel.Composition.Hosting.ImportEngine.PartManager.TryOnComposed()
at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportsStateMachine(PartManager partManager, ComposablePart part)
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(ComposablePart part, ExportDefinition export, Boolean isSharedPart)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.CatalogExport.GetExportedValueCore()
at System.ComponentModel.Composition.Primitives.Export.get_Value()
at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValuesCore[T](String contractName)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValues[T](String contractName)
at SiivasaAppClient.MefBootstrapper.GetInstance(Type serviceType, String key)
at Caliburn.Micro.BootstrapperBase.DisplayRootViewFor(Type viewModelType)
at Caliburn.Micro.BootstrapperBase.DisplayRootViewFor[TViewModel]()
at SiivasaAppClient.MefBootstrapper.OnStartup(Object sender, StartupEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(UInt32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)


This the code I'm using to import the viewModel

[Import]
Infrastructure.ViewModels.MainPageViewModel mainView = null;


Thank you for your help.
Viewing all 265 articles
Browse latest View live


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