MvvmLight应用程序中的Rest API客户端提供了Error ActivationException:在缓存中找不到类型:Microsoft.Rest.ServiceClientCredentials

时间:2018-08-28 09:00:11

标签: mvvm-light rest-client

在MVVMLight WPF应用程序中,我添加了Rest API客户端,然后将API接口注入到视图模型中

    public WLSViewModel(IABRAPI aBRAPI)
    {
        _ABRAPI = aBRAPI;
 }

以及我拥有的viewModelLocator

    static ViewModelLocator()
    {
      //  new AnonymousCredential();
        ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

        SimpleIoc.Default.Register<AnonymousCredential>(true);
        SimpleIoc.Default.Register<IABRAPI, ABRAPI>();
        SimpleIoc.Default.Register<MainViewModel>();
        SimpleIoc.Default.Register<WLSViewModel>();
    }

    /// <summary>
    /// Gets the Main property.
    /// </summary>

    public MainViewModel Main
    {
        get
        {
            return ServiceLocator.Current.GetInstance<MainViewModel>();
        }
    }
    public WLSViewModel WLS
    {
        get
        {
            return ServiceLocator.Current.GetInstance<WLSViewModel>();
        }
    }

但由于出现此错误而无法使其工作

ActivationException:在缓存中找不到类型:Microsoft.Rest.ServiceClientCredentials。

我想注册

的AnonymousCredential()
using Microsoft.Rest;
namespace liLib
{
    public class AnonymousCredential : ServiceClientCredentials
   {
   }
}

将使Microsoft.Rest.ServiceClientCredentials可用,但现在无济于事,我无法获得任何帮助

0 个答案:

没有答案