I recently worked on a c# class library project where I had some issues with a NuGet package. I installed the System.Configuration.ConfigurationManager package to my project, version 5.0.0. My class library is targeting .Net Standard 2.0. Everything works as expected on my local machine and compiles fine, but after publishing and deploying my project to the app server, I received this error:
FATAL | 04/13/2021_11:10:09 | System.IO.FileLoadException:
File name: 'System.Configuration.ConfigurationManager, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
---> System.IO.FileLoadException: 0x80131621
at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args)
at System.Runtime.Loader.AssemblyLoadContext.InvokeResolveEvent(ResolveEventHandler eventHandler, RuntimeAssembly assembly, String name)
at System.Runtime.Loader.AssemblyLoadContext.OnAssemblyResolve(RuntimeAssembly assembly, String assemblyFullName)
at MyProject.Batch.Standard.AppConfiguration..ctor()
From my understanding this means that the dll was found, but was unable to load it. After some playing around, I downgraded the version of the System.Configuration.ConfigurationManager package to 4.7.0 and it worked! I am wondering why the one version of the package worked while the other did not? The description of the two versions is nearly identical, which only the publish date ad the version of the depencies being different. I am not super familiar with NuGet, so if there is something super obvious that I missed that could help me avoid fighting with this for hours then please do tell! And if I haven't supplied sufficient information I can also update the question.
User contributions licensed under CC BY-SA 3.0