Microsoft.Practices.ServiceLocation.ActivationException



我正在尝试使用ServiceLocator 创建一个实例

/// <summary>
/// Gets the MediaPlayer property.
/// </summary>
[SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "This non-static member is needed for data binding purposes.")]
public MediaPlayerViewModel MediaPlayer
{
    get
    {
        try
        {
            return ServiceLocator.Current.GetInstance<MediaPlayerViewModel>();
        }
        catch (Exception e)
        {
            System.Console.WriteLine(e.ToString());
            return null;
        }
    }
}

但我得到了以下解释:

Microsoft.Practices.ServiceLocation.ActivationException未处理按用户代码HResult=-2146233088消息=发生激活错误在尝试获取MediaPlayerViewModel类型的实例时,键"
Source=Microsoft.Practices.ServiceLocation StackTrace:位于Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(类型serviceType,字符串键)c: \Projects\CommonServiceLocator\man\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line53位于Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstanceTService在里面c: \Projects\CommonServiceLocator\man\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line90位于Verint.PI2.MediaPlayer.UI.ViewModel.ViewModelLocator.get_MediaPlayer()在c:\Users\ekreiczer\Documents\Visual Studio中2012\Projects\player\Verint.PI2.MediaPlayer.UI\ViewModel\ViewModelLocator.cs:line73内部异常:Microsoft.Practices.Unity.ResolutionFailedExceptionHResult=-2146233088消息=解析依赖项失败,类型="Verint.PI2.MediaPlayer.UI.ViewModel.MediaPlayerViewModel",名称="(无)"。解析时发生异常。例外情况是:InvalidOperationException-当前类型,Verint.PI2.MediaPlayer.UI.Services.IDialogService,是一个接口和无法构建。您是否缺少类型映射?

我不知道怎么打地图,有人能帮忙吗?

MediaPlayerViewModel很可能取决于Verint.PI2.MediaPlayer.UI.Services.IDialogService的实现。

查看构造函数和MediaPlayerViewModel的属性来验证这一点。

您忘记将Verint.PI2.MediaPlayer.UI.Services.IDialogService映射到引导程序中的实现。

相关内容

  • 没有找到相关文章

最新更新