This is going to be one of those questions for which there are hundreds of answers, so please bare with me as I have tried most of them!
I have been breaking up a very large project into smaller components with the view to slowly migrate it all to .NET Core.
Some Projects in my solution are now .NETstandard class libraries, and there are also some .Net Framework (4.7.8) projects.
I was getting on quite well today when suddenly I started getting this:
Could not load file or assembly 'ServiceStack.Text, Version=22.214.171.124, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
The version installed in my projects is (was - read on...) 126.96.36.199
Now, I am not new to this error, I've found it before and it usually relates to either a project reference file, web.config or packages.config referencing a .DLL with a different version than that of the file in the
So I have been through all (34) project folders and deleted servicestack.text.dll in every project.
I have uninstalled it via NuGet in every project and reinstalled it.
I have checked every project's packages.config file and where they are .NETStandard projects, the project files and made sure that there are not references to ServiceStack.Text v 188.8.131.52
I have rebuilt, cleaned and restarted the solution, visual studio and my computer many times!
Then I noticed something...
In my .Net Framework projects, under References, if I click on the ServiceStack.Text file and view the Reference Properties, it shows Version: 184.108.40.206, but the Path is directing it at 220.127.116.11.
In the .NETStandard projects, it shows the correct version.
So then I thought maybe 5.9 can't work in the Framework projects, so I uninstalled it from every project and installed v 18.104.22.168 in every project. This then wouldn't build because Visual Studio threw errors in the .NETStandard projects saying "downgrade detected, please restore the updated version"
SO then I installed 5.9 (which is now the latest version) into all the .NETStandard projects, leaving 22.214.171.124 in the .NET Framework ones.
Now it will build, but the
FileNotFound exception throws again when I try to run it.
So I have tried;
objdirectories, cleaning and rebuilding
Wasted most of the day on this, so turned to SO... I do hope someone can help!
Right.... Answering my own Question again...
After a lot of messing about I found out what was happening, and it was nothing to do with Visual Studio builds, or .package file conflicts
The reason the error suddenly appeared was a call to
Dump() in something I was testing, which had another call to
Dump() in a preceding function referencing a different .NET Framework. Whilst according to Microsoft this (mixing Frameworks) works,
ServiceStack has different versions and it caused a version conflict.
In case anyone else runs into this, here's what I have found…
Pseudo code example… a function in a .NET Standard Project (2.0)
Function Blah() as Something … do something Log(TestResult.Dump()) Return Something End Function
And then a .NET Framework (4.7.8) Project which consumes this and again tries the Dump the result:
Sub DoSomething() Dim Something = Blah() Write(Something.Dump()) End Sub
The two frameworks require different versions of
ServiceStack.Text and therefore throw a confusing, though I guess correct,
FileNotFoundException in the running project.
I’m sure to run into this one again….!
User contributions licensed under CC BY-SA 3.0