After making the changes detailed recently where I upgraded the
.csproj project file format for a personal project, I found that the command line tool compiled by the project failed to work.
When run, it gave the following error:
(I’ve elided some of the detail to highlight the actual error.)
Clearly, this isn’t satisfactory, so I need to resolve the issue pretty quickly - this is a tool I use all the time. The good news is that all of the unit and integration tests run properly, so I have some confidence the problem was just with the
dfcmd project - which is a fairly simple console application over the rest of the system.
As I write this, I don’t know what the solution is going to be - this blog post is just following along as I investigate the problem.
In my experience, the “or one of its dependencies” part of the above error message often conceals hide a whole lot of detail, so I need to know more about the exact problem the program encounters.
I’ll use the Assembly Binding Log Viewer (also known as the fusion log viewer) - a tool that’s been around since the start of .NET to dig into this. It’s a part of your Visual Studio installation.
Running “Developer Command Prompt for VS 2017” in elevated (Administrator) mode, I run
To capture the error, I pressed “Settings” and selected “Log bind failures to disk”. (I need to remember to come back and set this to “Log Disabled” when I’m finished, otherwise I’ll start filling my disk with useless log files.) I neglected to run this from an elevated command prompt the first time and I couldn’t change any of the settings.
To start with a clean slate, I pressed “Delete All”, reproduced the error, then pressed “Refresh” to see what errors had occurred.
Opening the first log entry in a browser showed a very readable log that clearly explained what had happened. Here are the relevant lines (lightly edited for display):
Checking my project in Visual Studio, the project was referencing the
System.Runtime.Extensions NuGet package, but at version 220.127.116.11. Digging further, I find the error in my
app.config file; as reported above, it appears to be redirecting to the wrong version:
Changing this to reflect the version of the NuGet package (v18.104.22.168) is my first fix; after a rebuild of the application, that error no longer appeared in the fusion log viewer.
Unfortunately, the application still crashed with exactly the same error:
Clearly, the second error showing in the log viewer needed to be addressed as well. That one wasn’t so easy to fix.