【问题标题】:Prism Could not Found Services棱镜找不到服务
【发布时间】:2022-10-19 22:06:46
【问题描述】:

这是入门 Prism 示例的第一步 here

使用 System.Windows;

使用 Prism.Ioc;

使用 Prism.Unity;

命名空间 WpfApp1

{

public partial class App : PrismApplication
{
    protected override void RegisterTypes(IContainerRegistry containerRegistry)
    {
        containerRegistry.Register<Services.ICustomerStore, Services.DbCustomerStore>();
        // register other needed services here
    }

    protected override Window CreateShell()
    {
        var w = Container.Resolve<MainWindow>();
        return w;
    }
}

}

问题出在这一行containerRegistry.Register<Services.ICustomerStore它在哪里找到服务也建议两个,但没有一个具有以下客户商店

【问题讨论】:

    标签: prism


    【解决方案1】:

    服务是您在解决方案中创建的一个项目,它充当访问数据库的层。 ICustomerStore 是您提供给 DI 容器的接口,而 DbCustomerStore 是访问数据库的实现。因此,例如,一个非常简单的版本可能如下所示:

    ICustomer.cs:

    public interface ICustomer {
        List<Customer> GetAllCustomers();
    }
    

    数据库客户.cs:

    public class DbCustomer {
    

    【讨论】:

      猜你喜欢
      • 2021-12-05
      • 2022-07-13
      • 2020-04-29
      • 2019-02-08
      • 1970-01-01
      • 1970-01-01
      • 2017-06-15
      • 2020-10-04
      • 2019-08-13
      相关资源
      最近更新 更多