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:
↧