簡體   English   中英

asp.net核心FileNotFoundException新鮮項目

[英]asp.net core FileNotFoundException fresh project

我剛剛創建了新的asp.net core 1.1 Web應用程序,添加了nuget包

 Microsoft.EntityFrameworkCore
 Microsoft.EntityFrameworkCore.SqlServer

和我其他項目的參考

MySolution.Core
MySolution.Models
MySolution.Utilities

如果我將HomeController保留為創建狀態,則示例站點運行良好。 但是當我將下一個代碼添加到HomeController中時

public class HomeController : Controller
{
    private readonly MyRepository _repository;

    public HomeController(MyRepository repository)
    {
        _repository = repository;
    }
    public async Task<IActionResult> Index()
    {
        return View();
    }
}

應用運行時出現錯誤:處理請求時發生未處理的異常。

FileNotFoundException: Could not load file or assembly 'MySolution.Models, Version=1.0.0.0, 
Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

System.Signature.GetSignature(Void* pCorSig, int cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)

建模項目引用實體框架包。

我該如何解決該錯誤?

因此缺少DI配置。

使用您的Startup.cs配置依賴項

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM