I have an ASP.Net project which has several sub projects referenced.
I decided today to update some of my nuget packages to have newer versions, what a mistake it was.
Now when I try to debug my app I get this exception:
System.IO.FileNotFoundException: 'Could not load file or assembly
'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The
system cannot find the file specified.'
InnerException : FileNotFoundException: Could not load file or assembly
'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The
system cannot find the file specified.
It seems like it's looking to load 6.0.0.0 which is not referenced by any of my subprojects, maybe one of the other nugetpackages ?
I've followed several questions here to perform different operations including:
- Deleting packages folder in Windows Explorer
- Reinstalling the Newtonsoft.Json package
- Clearing the cache of the package in the settings of VS
- Restoring the packages
- Cleaning my solution
- Restarting VS
I'm using VS 2017 community.
I tried to update several other packages to see if it could be linked and I got many new exceptions so I just decided to stop the mess and rollback everything.
But the problem is still here after the rollback so i'm really unsure about what I should do now.
Links I've checked before: Nuget package installed but references not resolved
https://learn.microsoft.com/en-us/nuget/consume-packages/package-restore-troubleshooting
Related
Searched SO but can't find a solution that works.
In Visual I've got a main project. It uses another project (ProjectA) that compiles to a DLL. That project uses Servicestack ORMLite 4.5.14. I've also installed Mysql.Data 6.9.12. ProjectA is reference in the main project by Project, not by compiled DLL.
The compiled application is copied to an other PC (just copy, no install) and started. However, when it tries to access the database using ProjectA I get the following error:
System.IO.FileLoadException: Could not load file or assembly 'MySql.Data, Version=8.0.20.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'MySql.Data, Version=8.0.20.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' ---> System.IO.FileLoadException: Could not load file or assembly 'MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
at ServiceStack.OrmLite.MySql.MySqlDialectProvider.CreateConnection(String connectionString, Dictionary`2 options)
at ServiceStack.OrmLite.OrmLiteConnection.get_DbConnection()
at ServiceStack.OrmLite.OrmLiteConnection.Open()
at ServiceStack.OrmLite.OrmLiteConnectionFactory.OpenDbConnection()
at ServiceStack.OrmLite.OrmLiteConnectionFactoryExtensions.Open(IDbConnectionFactory connectionFactory)
at ProjectA.Repositories.ARepository.FindById(String id)
at ProjectA.Controllers.AController.FindById(String id)
at ProjectA.Service.DatabaseService.Find(String id)
What I've tried to solve the issue:
Compiled ProjectA and used the DLL as a reference instead of the project directly in the solution
Uninstalled all references of Mysql.Data and ServiceStack ORMlite and reinstall it
Changed .Net framework versions (4.5.2 and up)
Install the Mysql Connector on the machine where the application should run
Instlled Mysql.Data 8.0
Deleted the mysql.data.dll in the directory so it would be copied back. Checked the version of the DLL and it matches 6.9.12
Searched in the .csproj files for Mysql.data 8.0 and 6.9.9 but could not find a reference
Since it's using an old Mysql Server an older version of Mysql.Data is needed so also an older version of ServiceStack ORM lite.
I had this problem before, ProjectA is also used in a different project where Mysql 8.0 is needed. Since it's referenced as a project (not a DLL file) this changes back and forth. However, in the past reinstalling Mysql.data and Service Stack ORM lite did solve the issue. But now I'm unable to get past this error. I made sure the versions are the same for all projects in the solution. I'm aware this is bad practice but since we are rewriting the complete application was workable until now.
Any suggestions to solve this issue?
Turns out there was a cache directory in the obj with an service stack xml file referencing Mysql.Data version 6.9.9. Even after deleting the ServiceStack and Mysql.Data packages using NuGet package manager and reinstalling the correct version, this version number showed up in the ServiceStack xml file in de debug build directory.
Uninstalling ServiceStack and Mysql.Data packages, deleting the build directories (debug and release), deleting the obj directory, reinstalling the ServiceStack and Mysql.Data packages solved the problem.
Thanks for the answers #jdwang and #user9938.
I am refering a C# library project from my Azure Function (Service bus queue trigger). The library is referencing the Newtonsoft nuget version 10.0.1.
While running the function locally on my visual studio, it gives this error .
{"Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.":"Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"}
I tried downgrading to version 10.0.0, but the issue is there.
I stumbled upon this issue link : https://github.com/Azure/azure-functions-vs-build-sdk/issues/107.
And tried downgrading to 9.0.1. But even then the error still occurs.
Note: The library project reference several other library projects which are also referencing Newtonsoft. I am keeping the same version of the nuget all the sub projects.
How to solve this issue?
Pointing all the Newtonsoft dlls in all the sub libraries to version to 9.0.1 solved the issue.
I have a OneClick program, Project A, that references class library project B. Project B had Json.net version 4.5.0.0 that was upgraded to 7.0.0.0. Upon building project A I get the error messages:
No way to resolve conflict between "Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". Choosing "Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" arbitrarily.
Consider app.config remapping of assembly "Newtonsoft.Json, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" from Version "4.5.0.0" [C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\Newtonsoft.Json.dll] to Version "7.0.0.0" [[projectpath]\Newtonsoft.Json.dll] to solve conflict and get rid of warning.
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3276: Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190.
I have cleaned every project in the solution and rebuilt them. I've closed/opened VS, recleaned, rebuilt, same thing. Manually deleted obj + bin folders, same thing.
I've changed the Settings/Publish/Application Files menu to every variation of inclusion/exclusion for json.net.
And finally, I've global searched in Sublime(VS doesn't pick up everything) for 4.5.0.0 and come up with virtually nothing except the json.net references in the manifest files project A creates. I can't seem to find a single lingering reference to the old library, yet it keeps ending up in the manifest upon building.
I've solved my problem by adding <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> in the .csproj's relevant <PropertyGroup>s, but I'm not sure why it works. Can anyone explain to me what's going on? Is this a bad way to solve this problem?
I'm getting the following exception when trying to use the Google Auth API:
System.IO.FileNotFoundException : Could not load file or assembly 'System.Net.Http.Primitives, Version=4.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
----> System.IO.FileNotFoundException : Could not load file or assembly 'System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
The exception happens in Google.Api.Core.dll.
If I check the /Bin folder I can see Sytem.Net.Http.Primitives.dll in there and the version is 4.2.28.0.
I have tried updating the Microsoft HTTP Client Libraries NuGet package but that didn't help.
Is the problem something to do with a mismatch of .dll versions? If so how can I resolve that? Or is it something else entirely?
Double check if the assembly file is there in the bin folder and if its there, then try removing the reference and again add it to your project.
The version should be the same as expected. Also check on your web.config too for what it has about this particular assembly.
In your error code, I can see two different versions for the same file. Means probably, you are getting a clash between the existing assembly and the referenced assembly. Check you web.config for which version is referenced there and make sure you have the same version added to your project.
This link might help :
Could not find assembly System.Net.Http.Primitives
I recently added the package LinqToExcel to my .net 4 WPF project and now when entering the designer I am presented with the following error:
System.IO.FileNotFoundException
Could not load file or assembly 'Castle.DynamicProxy2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The system cannot find the file specified.
LinqToExcel only has one dependency - log4net, which it installed as part of the NuGet process. Both are referenced and set to Copy Local. I'm not sure where the reference to Castle is coming from or how to go about fixing it.
Does anyone have any suggestions?