This project has moved and is read-only. For the latest updates, please go here.

Batch not including specific part - solved

Apr 25, 2010 at 2:23 AM

I had a fairly weird problem that I thought I'd share in the interest of saving someone else some time.

This code is fairly old, but it worked in .NET 3.5. It is not working in .NET 4.

The parent is _container and the child is container.

The symptom is that the explicit part is not added to the container. The part is contained in the batch, which I have confirmed via the Immediate window. I'm new to the visualization, but it confirms what I'm seeing that the child contianer is identical to the parent.

Also, the imports in the explicit part are not resolved. They are Imports without defaults so if there was a problem with them, I should get an error, which I do not.

An exception is not thrown.

The problem turned out to be mixed versions of Compositin.dll - from early December and the 4.0 version. This had me stuck until I got a 'ambiguous' error in the same namespace, which often means competing dlls.

      Private Function ComposeChild( _
              ByVal catalogs() As Primitives.ComposablePartCatalog, _
              ByVal parts() As Object) _
              As Boolean
         Dim aggregate As AggregateCatalog
         Dim container As CompositionContainer
            aggregate = New AggregateCatalog(catalogs)

container = New CompositionContainer(aggregate, True, _container)
            Dim batch = New CompositionBatch()
            For Each part In parts
               If part IsNot Nothing Then
               End If
#If DEBUG Then
            Dim uriPath = New Uri(Reflection.Assembly.GetExecutingAssembly.CodeBase)
            Dim dgmlPath = Uri.UnescapeDataString(uriPath.AbsolutePath)
            dgmlPath = IO.Path.GetFullPath(IO.Path.Combine(dgmlPath, "..\..\.."))
            Dim meftoDgml = New E4D.MEFVisualizer.MEFToDGML(container) _
                            With {.Path = dgmlPath, .FileName = "Initial"}
#End If
            '      Me._container.Compose(batch)
#If DEBUG Then
            Dim meftoDgml2 = New E4D.MEFVisualizer.MEFToDGML(container) _
                            With {.Path = dgmlPath, .FileName = "Child"}
#End If
         Catch ex As Exception
         End Try
         Return True
      End Function