Sei sulla pagina 1di 4

27/03/2019 Resolve version error (CS1705) through Package Manager Console - CodeProject

13,906,223
Sign up formembers
our free weekly Web Dev Newsletter. Sign in
×

Search for articles, questions, tips


articles Q&A forums stuff lounge ?

Resolve version error (CS1705) through Package


Manager Console
Benktesh Sharma, 22 Mar 2019

   1.00 (2 votes) Rate this:

How to handle 'Which has higher version than referenced assembly' error (Error CS1705) through Package Manager Console

Introduction
Where there are multiple project within the solution and one project is dependent on other, and versions introduce breaking
changes, we sometimes encounter package version conflict and Visual Studio solution does not build. It may return the following
error:

Error    CS1705    Assembly 'WebAPI' with identity 'WebAPI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses
'Microsoft.AspNetCore.Mvc.Core, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' which has a higher version
than referenced assembly 'Microsoft.AspNetCore.Mvc.Core' with identity 'Microsoft.AspNetCore.Mvc.Core, Version=2.1.0.0,
Culture=neutral, PublicKeyToken=adb9793829ddae60'    WebApiTest    C:\... 
 

The above error can be produced on a solution that uses two projects, namely WebApi and WebApiTest. 

Background
The error above shows that the test project and API project are using a different version of Microsoft.AspNetCore.Mvc.Core. For
example, the test project is using version 2.1.0.0 while the API project is using 2.1.1.0.

We can resolve this issue by updating the package reference in either of the projects to match. For example, we can update the
WebApiTest project to use the higher version of the assembly (i.e., at 2.1.1.0) or downgrade the assembly version in the WebApi
project to 2.1.0.0 depending on the need.  
 

Resolution Example
We can issue a command like below in the package manager console targetting the right project. For example, the code below will
update the assembly reference for Microsoft.AspNetCore.Mvc.Core on WebApiTest test to use version 2.1.1.0. This will then match
the version of the same assembly in the WebApi project.  The following code 

Hide   Copy Code


Install-Package Microsoft.AspNetCore.Mvc.Core -Version 2.1.1.0 -ProjectName WebApiTest

https://www.codeproject.com/Tips/1280404/Resolve-version-error-CS1705-through-Package-Manag 1/4
27/03/2019 Resolve version error (CS1705) through Package Manager Console - CodeProject

The argument '- ProjectName WebApiTest' name can be omitted if the correct project is selected in the dropdown that is available
in the Package Manager Console window in the Visual Studio. An example of screen shot is shown in the figure below:

Figure: Package Manager Console window in Visual Studio 2017 running on Windows machine.

Likewise, to update the WebApi project instead, the following command will do the trick:

Hide   Copy Code


Install-Package Microsoft.AspNetCore.Mvc.Core -Version 2.1.1.0 -ProjectName WebApiTest

History
03/21/2019. Added an image of a package manager console.

03/20/2019. First Commit

License
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

https://www.codeproject.com/Tips/1280404/Resolve-version-error-CS1705-through-Package-Manag 2/4
27/03/2019 Resolve version error (CS1705) through Package Manager Console - CodeProject

Benktesh Sharma
United States

Benktesh is member of an amazing IT Lending development team at Cuna Mutual Financial Group (CMFG) in Madison WI where
he is a software developer/architect. His main focus when coding is quality, simplicity and scalability and he is experienced in a
broad range of subjects (software design, software development process, project management, testing, UI, multithreading,
database, mobile development, and more).

Outside of professional work, there is always some side projects he is working on such as simulation modeling of forest
management and carbon quantification and writing articles both technical and non-technical. While not coding, he is occupied
with reading, watching tv shows, trading stocks, and discuss climate change, global warming, emission trading, and traveling to
meet people, place and culture.

You may also be interested in...


A Solution Blueprint for DevOps Public, Private, and Hybrid Cloud: What's the
difference?

Watchdog Management A Regular Expression Engine in C#

Remoting Management Console Getting startet with OpenGL/OpenTK in


MONO/.NET for serious applications

Comments and Discussions


 

You must Sign In to use this message board.

Search Comments

-- There are no messages in this forum --

https://www.codeproject.com/Tips/1280404/Resolve-version-error-CS1705-through-Package-Manag 3/4
27/03/2019 Resolve version error (CS1705) through Package Manager Console - CodeProject

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile


Selecione o idioma ▼
Web05 | 2.8.190306.1 | Last Updated 22 Mar 2019
Layout: fixed | fluid Article Copyright 2019 by Benktesh Sharma
Everything else Copyright © CodeProject, 1999-2019

https://www.codeproject.com/Tips/1280404/Resolve-version-error-CS1705-through-Package-Manag 4/4

Potrebbero piacerti anche