question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Microsoft.AspNetCore.Mvc, Version=2.2.0.0 is giving an error "System.IO.FileNotFoundException"

See original GitHub issue

I have started using .Net Core 2.2 recently and I got one WebApp related test cases there, where I am using

TestServer

from

Microsoft.AspNetCore.TestHost

. While executing the test cases I am seeing below error:

System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.AspNetCore.Mvc, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
   at <my code related to Startup.ConfigureServices>
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize()
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at Microsoft.AspNetCore.TestHost.TestServer..ctor(IWebHostBuilder builder, IFeatureCollection featureCollection)
   at <my test>

My Visual studio version is: Professional 2017 15.9.3. The same piece of code used to work with .Net Core 2.0. Is it kind of regression?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

38reactions
KevMcommented, Dec 18, 2018

I fixed this by following this guide and adding a missing package reference to my integration test project.

<PackageReference Include="Microsoft.AspNetCore.App" />

I had to do a clean and restart of VS 2017 before the change allowed my tests to pass once more.

13reactions
jaydeeptcommented, Dec 11, 2018

I have found the workaround, You need to install the package “Microsoft.AspNetCore.Mvc”, the latest version though it’s not required by your project. I think TesHost package is referring to old version and that’s why this issue occurred.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not load file or assembly 'Microsoft.AspNetCore. ...
Appreciate any help. The error is. System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Connections.Abstractions, ...
Read more >
ASP.NET Core 3.1.0 site won't run - Could not load ...
I'm building an ASP.NET Core app, and it's stored on an Azure web ... System.IO.FileNotFoundException: Could not load file or assembly ...
Read more >
.NET Framework app fails with "Could not load file or ...
Executing a .NET Framework 4.6.1 console app that references a .NET Standard 2.0 assembly fails with Unhandled Exception: System.IO.
Read more >
VS2019 16.3 Azure Functions Tools fails build due to ...
AspNetCore.Mvc.Abstractions V2.2.0.0Closed - Fixed ... System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.
Read more >
Active questions tagged nuget-package - Stack Overflow ...
I am using ASP.NET Core framework to build an API with Azure Key Vault. I tried to follow this tutorial but I am...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found