Have you ever gotten this message?
Assembly ‘[X]’ uses ‘[Y]’ which has a higher version than referenced assembly ‘[Z]’.1
It’s caused me some grief at times, and the available resources online for resolving this issue aren’t the most clear, I thought I’d present my findings on this error.
When I received this problem, I was working on a solution that had one project that was dependent on another project within the solution. Both of these projects referenced EntityFramework, and the EF package was provided by NuGet. I got this problem shortly after updating my NuGet packages. There are other causes of this error, I know. If I encounter them, I’ll edit this post.
I tried cleaning and rebuilding the project, but to no avail. This error continued on and on through subsequent rebuilds.
Finally, what I did to resolve this was navigate to the bin/ directory of the project that was reporting the error. I found that there was a lingering Entity Framework DLL for the old version. The simple solution was to remove this DLL. I rebuilt the solution, and it worked.
I’m not sure why this happens, but my theory is that when you update a package, the old version isn’t cleaned up from the build area. This makes sense, as you don’t want to mess up your successful build.
However, when the package reference is updated, it might not update the build manifest properly. This might cause the subsequent builds to get confused with the lingering old DLLs. The build process most likely does not realize that this file needs to be cleaned up.
If you are working on either a collaborative project or one that makes use of external libraries (especially via NuGet), the best way I’ve found to avoid this problem is to issue a Clean before you update.
If you have encountered any other tricky cases in which this has happened, feel free to share it below.
No comments:
Post a Comment