MEF Error message
Can anybody explain this error message:
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 pro开发者_开发知识库vided below. Review the CompositionException.Errors property for more detailed information.
1) No valid exports were found that match the constraint '((exportDefinition.ContractName == "Silverbits.ApplicationServices.ApplicationServicesManager") AndAlso (exportDefinition.Metadata.ContainsKey("ExportTypeIdentity") AndAlso "Silverbits.ApplicationServices.ApplicationServicesManager".Equals(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))', invalid exports may have been rejected.
Resulting in: Cannot set import 'Silverbits.Applications.SilverbitsApplication.ApplicationServices (ContractName="Silverbits.ApplicationServices.ApplicationServicesManager")' on part 'Framework.App'. Element: Silverbits.Applications.SilverbitsApplication.ApplicationServices (ContractName="Silverbits.ApplicationServices.ApplicationServicesManager") --> Framwork.App
While the ApplicationServicesManager
class may be available and marked with an [Export]
attribute, this part may still have been rejected because it has itself imports which cannot be satisfied.
Take a look at the section Diagnosing Composition problems in the MEF documentation.
It's looking for something like this:
[Export]
public class ApplicationServicesManager
{
}
or like this:
public class SomeClass
{
[Export]
public ApplicationServicesManager AppServices { get; private set; }
}
But it can't find one in the scope of your provided exports. If you're Exporting it from a property or field, make sure the object exporting it has been composed with the container. If it's a class export and the class is present in another assembly, make sure the assembly is in the container's catalog.
精彩评论