0
我想將部件的MEF組成部分抽象成類庫類,但由於ComposeParts擴展方法在類庫中不可用,因此在.Net4.5 RC中出現問題CompositionContainerMEF CompositionContainer Missing ComposeParts擴展方法
我做錯了什麼或可能缺少參考?
WCF服務類工作容器
<Import(GetType(IGenericModelFactory))>
Public Property ModelFactory As IGenericModelFactory
Private _mefContainer As CompositionContainer
Private _catelog As DirectoryCatalog
Public Sub New()
_catelog = New DirectoryCatalog(".")
_mefContainer = New CompositionContainer(_catelog)
_mefContainer.ComposeParts(Me)
End Sub
類庫 - 缺少ComposeParts方法
Imports System.ComponentModel.Composition.Hosting
Namespace Core.Composition
Public Class CompositionBuilder
Implements IComposeObjects
Public Function CreateContainer() As CompositionContainer Implements IComposeObjects.CreateContainer
Return Activator.CreateInstance(Of CompositionContainer)()
End Function
Public Sub ComposeFromDirectory(directory As String, compositionRoot As Object) Implements IComposeObjects.ComposeFromDirectory
Dim catelog As DirectoryCatalog = Activator.CreateInstance(GetType(DirectoryCatalog), directory)
Dim mefContainer As CompositionContainer = Activator.CreateInstance(GetType(CompositionContainer), catelog)
mefContainer.Composeparts(compositionRoot)
End Sub
End Class
End Namespace