Tips on Debugging AddExportedValue

Jan 14, 2010 at 7:47 PM

I need to add some stray values (from a config file) to my container. I am using the code that follows. The exports are placed into the batch, but they are not in the resulting container. Any tips on where to start debugging this? The parts I am trying to add are strings with string contracts.

Thanks!

         CompositionBatch batch = new CompositionBatch();
         if (!_partsToAdd.Contains(this))
         {
            _partsToAdd.Add(this);
         }
         foreach (var p in _partsToAdd)
         {
            if (p != null)
            { batch.AddPart(p); }
         }
         foreach (var pair in _exportData)
         {
            batch.AddExportedValue<object>(pair.Key, pair.Value);
         }
         if (parent == null)
         {
            _compositionContainer = new CompositionContainer(_aggregateCatalog);
         }
         else
         {
            var parentContainer = ((ExportingCompositionContainer)parent)._compositionContainer;
            _compositionContainer = new CompositionContainer(_aggregateCatalog, parentContainer);
         }
         try
         {
            _compositionContainer.Compose(batch);
         }

Jan 14, 2010 at 8:05 PM

Actually I misunderstood the problem.

This is working correctly, my reporting was not as it used the catalog. It seems that things added directly to the batch do not show up in the catalog.

Jan 14, 2010 at 8:48 PM

Yes, parts in the batch are added to an export provider in the container not to catalogs. It is not visible on the public API.

Glenn