So I've run into a problem when running a few powershell azure functions (v 6.2.7) on a function app with runtime version 2.0.14494.0 when trying to use a 3rd party nuget that has a dependency on v4.7.0 of the system.configuration.configurationmanager nuget. However, when I try and use the necessary 3rd party nuget from powershell, I consistently get exceptions saying that the
System.IO.FileLoadException: Could not load file or assembly
'System.Configuration.ConfigurationManager,
Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
It's probably useful to note here that the 3rd party nuget is explicitly compiled as x64 and is only compiled for net452, net462, netstandard2.0
I've checked, and our function app is configured as x64.
I've also looked and in the Program Files x86/SiteExtensions/Functions/2.0.14494.0 directory in Kudu on the azure function app I can see that the S.C.CM nuget listed there has a version of 4.0.3.0 but if I run the below as part of my powershell script:
[System.Configuration.ConfigurationManager]
Then I get output saying that the loaded dll is instead referencing the 4.0.1.0 version. Something like this:
2020-10-07T20:41:24.100 [Information] OUTPUT: DeclaredProperties : {Boolean SetConfigurationSystemInProgress, Boolean SupportsUserConfig, System.Collections.Specialized.NameValueCollection AppSettings, System.Configuration.ConnectionStringSettingsCollection ConnectionStrings}
2020-10-07T20:41:24.101 [Information] OUTPUT: ImplementedInterfaces : {}
2020-10-07T20:41:24.101 [Information] OUTPUT: IsInterface : False
2020-10-07T20:41:24.101 [Information] OUTPUT: MemberType : TypeInfo
2020-10-07T20:41:24.101 [Information] OUTPUT: Namespace : System.Configuration
2020-10-07T20:41:24.101 [Information] OUTPUT: AssemblyQualifiedName : System.Configuration.ConfigurationManager, System.Configuration.ConfigurationManager, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
2020-10-07T20:41:24.102 [Information] OUTPUT: FullName : System.Configuration.ConfigurationManager
2020-10-07T20:41:24.102 [Information] OUTPUT: Assembly : System.Configuration.ConfigurationManager, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
2020-10-07T20:41:24.102 [Information] OUTPUT: Module : System.Configuration.ConfigurationManager.dll
2020-10-07T20:41:24.108 [Information] OUTPUT: IsNested : False
(Note the 4.0.1.0 in the Version)
What could possibly be causing this? How can I fix this, if at all? Unfortunately because the nuget we're using isn't one we own, we can't just break the dependency on this other dll, so is there any way to get around this perceived behavior?