Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeLoadException: Could not load type IHttpResponseStreamWriterFactory from assembly

I'm building aspnet core app. I wanted to keep one of my MVC Controllers in Class Library (so outside main project).

In order to do that, I've created new class extending Controller in Class Library project called "DataSync". Then, I referenced it in Startup.cs file of main project:

services.AddMvc().AddApplicationPart(Assembly.Load(new AssemblyName("DataSync")));

Here is the error that I see when I try to open main project in browser:

TypeLoadException: Could not load type 'Microsoft.AspNetCore.Mvc.Internal.IHttpResponseStreamWriterFactory' from assembly 'Microsoft.AspNetCore.Mvc.Core, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Where should I look for possible problems? What could go wrong here?

like image 394
Piotrek Avatar asked Jun 26 '18 11:06

Piotrek


1 Answers

To fix that, I updated versions of libraries that where used by both projects (main project and class library) and ensured that versions are exactly the same. After that, the problem seem to disappear.

like image 64
Piotrek Avatar answered Oct 19 '22 11:10

Piotrek