1

我正在开发一个具有多个模块(用户、项目、付款、发票等)的应用程序。这些模块中的每一个都有一个对包含名为 App.Controls 的共享控件的公共模块的引用。App.Controls 包含一个名为 OKSaveDialogView 的视图,它只是一个带有确定/保存按钮和一些常用功能的外壳视图。OKSaveDialogView 动态加载适当的内容以实现可重复性。不幸的是,App.Controls 部分被多次加载到目录中,导致错误:

1) 找到多个与约束匹配的导出 '((exportDefinition.ContractName == "App.Controls.ViewModels.OkCancelDialogViewModel")

我什至不确定从哪里开始调试这是如何发生的。谁能指出我正确的方向?

以下是该项目的一些代码片段:

OKCaneclDialogView.Xaml.VB

<Export("OkCancelDialogView")> _
<PartCreationPolicy(CreationPolicy.NonShared)> _
Partial Public Class OkCancelDialogView
    Inherits UserControl

    Public Sub New()
        InitializeComponent()
    End Sub

    <Import()> _
    Public Property ViewModel() As OkCancelDialogViewModel
        Get
            Return Me.DataContext
        End Get
        Set(value As OkCancelDialogViewModel)
            Me.DataContext = value
        End Set
    End Property
End Class

OkCancelDialoViewModel.vb

<Export()> _
<PartCreationPolicy(CreationPolicy.NonShared)> _
Public Class OkCancelDialogViewModel
    Inherits ViewModelBase
    Implements INavigationAware
    Implements IPartImportsSatisfiedNotification
    'Implements IOkCancelDialogViewModel


    'Services
    'Private ReadOnly regionManager As IRegionManager
    Private WithEvents userService As IUserDataService

    Private navigationJournal As IRegionNavigationJournal

    Private Const UserIdKey As String = "PrimaryId"
    Private Const SecondaryIdKey As String = "SecondaryId"
    Private Const DialogContentKey As String = "DialogContent"

    'DialogViewModelDictionary
    Private DialogViewModelDictionary As DialogViewModelDictionaries

    Public Sub New()
        Me.New(New RegionManager)
    End Sub

    <ImportingConstructor()> _
    Public Sub New(regionManager As IRegionManager)
        'Setup the global region manager
        Me.RegionManager = regionManager

        'Setup the locally scoped region manager
        Me.LocalRegionManager = regionManager.CreateRegionManager

        Me.synchronizationContext = If(synchronizationContext.Current, New SynchronizationContext())

        'Setup commands
        Me._closeCommand = New DelegateCommand(AddressOf OnClose)

        Me._okSaveCommand = New DelegateCommand(AddressOf Me.OnOkSave, AddressOf Me.CanClickOkSave)
        Me._CancelCommand = New DelegateCommand(AddressOf Me.OnCancel, AddressOf Me.CanClickCancel)


        DialogViewModelDictionary = New DialogViewModelDictionaries
        DialogViewModelDictionary.AddDialogViewModel("EditAddressDialogView", New EditAddressDialogViewModel())
    End Sub
4

0 回答 0