NullReferenceException

Dec 23, 2009 at 9:14 AM

 

 

   at System.ComponentModel.Composition.Hosting.CompositionServices.MetadataList.ToArray() in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\CompositionServices.cs:line 286

   at System.ComponentModel.Composition.Hosting.CompositionServices.TryExportMetadataForMember(MemberInfo member, IDictionary`2& dictionary) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\CompositionServices.cs:line 221
   at System.ComponentModel.Composition.AttributedModel.AttributedExportDefinition.get_Metadata() in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\AttributedModel\AttributedExportDefinition.cs:line 47
   at System.ComponentModel.Composition.ReflectionModel.ReflectionMemberExportDefinition.get_Metadata() in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\ReflectionModel\ReflectionMemberExportDefinition.cs:line 49
   at System.ComponentModel.Composition.Primitives.ContractBasedImportDefinition.MatchRequiredMatadata(ExportDefinition definition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Primitives\ContractBasedImportDefinition.cs:line 230
   at System.ComponentModel.Composition.Primitives.ContractBasedImportDefinition.IsConstraintSatisfiedBy(ExportDefinition exportDefinition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Primitives\ContractBasedImportDefinition.cs:line 223
   at System.ComponentModel.Composition.Hosting.TypeCatalog.GetExports(ImportDefinition definition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\TypeCatalog.cs:line 225
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetExports(ImportDefinition definition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\AssemblyCatalog.cs:line 168
   at System.ComponentModel.Composition.Hosting.DirectoryCatalog.<>c__DisplayClass1.<GetExports>b__0(ComposablePartCatalog catalog) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\DirectoryCatalog.cs:line 259
   at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
   at System.ComponentModel.Composition.Hosting.AggregateCatalog.GetExports(ImportDefinition definition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\AggregateCatalog.cs:line 152
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\CatalogExportProvider.cs:line 260
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.cs:line 208
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.cs:line 102
   at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\AggregateExportProvider.cs:line 157
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.cs:line 208
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.cs:line 145
   at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\CompositionContainer.cs:line 396
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.cs:line 208
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.cs:line 102
   at System.ComponentModel.Composition.Hosting.ImportEngine.TryGetExports(ExportProvider provider, ComposablePart part, ImportDefinition definition, AtomicComposition atomicComposition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ImportEngine.cs:line 721
   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset(PartManager partManager, IEnumerable`1 imports, AtomicComposition atomicComposition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ImportEngine.cs:line 451
   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportsStateMachine(PartManager partManager, ComposablePart part) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ImportEngine.cs:line 345
   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager, ComposablePart part, Boolean shouldTrackImports) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ImportEngine.cs:line 423
   at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImports(ComposablePart part) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ImportEngine.cs:line 159
   at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\CompositionServices.cs:line 348
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(ComposablePart part, ExportDefinition export, Boolean isSharedPart) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\CatalogExportProvider.cs:line 432
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.CatalogExport.GetExportedValueCore() in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\CatalogExportProvider.CatalogExport.cs:line 46
   at System.ComponentModel.Composition.Primitives.Export.get_Value() in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Primitives\Export.cs:line 199
   at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\ExportServices.cs:line 204
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValueCore[T](String contractName, ImportCardinality cardinality) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.GetExportOverrides.cs:line 737
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValue[T](String contractName) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.GetExportOverrides.cs:line 536
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValue[T]() in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.GetExportOverrides.cs:line 486
   at Panther.App.DisplayShell() in c:\Working\junk\Panther\Panther\App.xaml.cs:line 84
   at Panther.App.Start() in c:\Working\junk\Panther\Panther\App.xaml.cs:line 76
   at Panther.App.Main(String[] args) in c:\Working\junk\Panther\Panther\App.xaml.cs:line 111
   at System.AppDomain._nExecuteAssembly(Assembly 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.Run(ExecutionContext executionContext, ContextCallback Icallback,

Object state)

   at System.Threading.ThreadHelper.ThreadStart()

 I got NullReferenceException when try to construct multiple [ImportMany] and scratched my head a couple times. Any idea what happened?

 

  at System.ComponentModel.Composition.Hosting.CompositionServices.MetadataList.ToArray() in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\CompositionServices.cs:line 286

   at System.ComponentModel.Composition.Hosting.CompositionServices.TryExportMetadataForMember(MemberInfo member, IDictionary`2& dictionary) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\CompositionServices.cs:line 221

   at System.ComponentModel.Composition.AttributedModel.AttributedExportDefinition.get_Metadata() in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\AttributedModel\AttributedExportDefinition.cs:line 47

   at System.ComponentModel.Composition.ReflectionModel.ReflectionMemberExportDefinition.get_Metadata() in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\ReflectionModel\ReflectionMemberExportDefinition.cs:line 49

   at System.ComponentModel.Composition.Primitives.ContractBasedImportDefinition.MatchRequiredMatadata(ExportDefinition definition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Primitives\ContractBasedImportDefinition.cs:line 230

   at System.ComponentModel.Composition.Primitives.ContractBasedImportDefinition.IsConstraintSatisfiedBy(ExportDefinition exportDefinition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Primitives\ContractBasedImportDefinition.cs:line 223

   at System.ComponentModel.Composition.Hosting.TypeCatalog.GetExports(ImportDefinition definition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\TypeCatalog.cs:line 225

   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetExports(ImportDefinition definition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\AssemblyCatalog.cs:line 168

   at System.ComponentModel.Composition.Hosting.DirectoryCatalog.<>c__DisplayClass1.<GetExports>b__0(ComposablePartCatalog catalog) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\DirectoryCatalog.cs:line 259

   at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()

   at System.ComponentModel.Composition.Hosting.AggregateCatalog.GetExports(ImportDefinition definition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\AggregateCatalog.cs:line 152

   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\CatalogExportProvider.cs:line 260

   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.cs:line 208

   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.cs:line 102

   at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\AggregateExportProvider.cs:line 157

   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.cs:line 208

   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.cs:line 145

   at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\CompositionContainer.cs:line 396

   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.cs:line 208

   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.cs:line 102

   at System.ComponentModel.Composition.Hosting.ImportEngine.TryGetExports(ExportProvider provider, ComposablePart part, ImportDefinition definition, AtomicComposition atomicComposition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ImportEngine.cs:line 721

   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset(PartManager partManager, IEnumerable`1 imports, AtomicComposition atomicComposition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ImportEngine.cs:line 451

   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportsStateMachine(PartManager partManager, ComposablePart part) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ImportEngine.cs:line 345

   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager, ComposablePart part, Boolean shouldTrackImports) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ImportEngine.cs:line 423

   at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImports(ComposablePart part) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ImportEngine.cs:line 159

   at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\CompositionServices.cs:line 348

   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(ComposablePart part, ExportDefinition export, Boolean isSharedPart) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\CatalogExportProvider.cs:line 432

   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.CatalogExport.GetExportedValueCore() in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\CatalogExportProvider.CatalogExport.cs:line 46

   at System.ComponentModel.Composition.Primitives.Export.get_Value() in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Primitives\Export.cs:line 199

   at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\ExportServices.cs:line 204

   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValueCore[T](String contractName, ImportCardinality cardinality) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.GetExportOverrides.cs:line 737

   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValue[T](String contractName) in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.GetExportOverrides.cs:line 536

   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValue[T]() in C:\Dev\Microsoft\MEF Preview 8\src\ComponentModel\System\ComponentModel\Composition\Hosting\ExportProvider.GetExportOverrides.cs:line 486

 

 

Dec 23, 2009 at 9:22 AM

It looks like I will get this problem when I don't set any property for the metadata interface... I will try to reproduce it in the smaller test case

May 17, 2013 at 9:49 AM
Hi all,
Seems that this post is the only one with the same problem as I have.
What was the cause of this issue?