![](/img/trans.png)
[英]FileNotFoundException when loading assembly of ASP.NET Core MVC 5 project
[英]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.