I have one module with interface IModuleMainService with one event.
e.g. [Export(typeof(IModuleMainService))]
I have SHELL with interface IMainService.
e.g. [Export(typeof(IMainService))]
In ModuleMain I have import [Import(typeof(IMainService)]
In this case application working, but I want to communicate with module and shell.
I try to insert importing to Shell.cs e.g.
[Import]
public IModuleMainService ModuleMainService { get; set; }
But I run application and I get error, see bellow. If I comment [Import] public IModuleMainService...
application running succesfull.
Where is a problem?
The Point is: Consum event of Module class in SHELL.
System.ComponentModel.Composition Warning: 1 : The ComposablePartDefinition 'Main.Silverlight.Views.Shell' has been rejected. The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) No valid exports were found that match the constraint '((exportDefinition.ContractName == "Main.ViewModels.ShellViewModel") AndAlso (exportDefinition.Metadata.ContainsKey("ExportTypeIdentity") AndAlso "Main.ViewModels.ShellViewModel".Equals(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))', invalid exports may have been rejected.
Resulting in: Cannot set import 'Main.Silverlight.Views.Shell.ViewModel (ContractName="Main.ViewModels.ShellViewModel")' on part 'Main.Silverlight.Views.Shell'. Element: Main.Silverlight.Views.Shell.ViewModel (ContractName="Main.ViewModels.ShellViewModel") --> Main.Silverlight.Views.Shell --> AssemblyCatalog (Assembly="Main, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
A first chance exception of type 'System.ComponentModel.Composition.ImportCardinalityMismatchException' occurred in System.ComponentModel.Composition