Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileLoadException on System.Configuration.ConfigurationManager with SDK 6.0.400-preview #159

Closed
rainersigwald opened this issue Jun 13, 2022 · 3 comments

Comments

@rainersigwald
Copy link
Member

Reported as dotnet/upgrade-assistant#1151 and related to dotnet/msbuild#7629.

System.IO.FileLoadException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
   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 Microsoft.Build.Locator.MSBuildLocator.<>c__DisplayClass15_0.<RegisterMSBuildPath>g__TryLoadAssembly|3(AssemblyName assemblyName)
   at Microsoft.Build.Locator.MSBuildLocator.<>c__DisplayClass15_0.<RegisterMSBuildPath>b__2(AssemblyLoadContext _, AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
   at Microsoft.Build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2 toolsets, ToolsetConfigurationReader configurationReader, PropertyDictionary`1 environmentProperties, PropertyDictionary`1 globalProperties, ToolsetDefinitionLocations locations)
   at Microsoft.Build.Evaluation.ProjectCollection.InitializeToolsetCollection(ToolsetConfigurationReader configReader)
   at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCount, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly, Boolean useAsynchronousLogging)
   at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties)
rainersigwald added a commit to rainersigwald/upgrade-assistant that referenced this issue Jun 13, 2022
dotnet/msbuild#7629 updated MSBuild's reference to
`System.Configuration.ConfigurationManager` to the current 6.0.0.0
version. That version is available in the SDK directory and
MSBuildLocator tries to load it but fails. Figuring out why is tracked
as microsoft/MSBuildLocator#159, but this works around the problem by
updating to (and thus redistributing) the same version that MSBuild now
references, which is compatible with older SDKs/MSBuilds as well.
rainersigwald added a commit to rainersigwald/upgrade-assistant that referenced this issue Jun 14, 2022
dotnet/msbuild#7629 updated MSBuild's reference to
`System.Configuration.ConfigurationManager` to the current 6.0.0.0
version. That version is available in the SDK directory and
MSBuildLocator tries to load it but fails. Figuring out why is tracked
as microsoft/MSBuildLocator#159, but this works around the problem by
updating to (and thus redistributing) the same version that MSBuild now
references, which is compatible with older SDKs/MSBuilds as well.
@rainersigwald
Copy link
Member Author

The same basic problem is the root cause of dotnet/sdk#26065, but there it's NuGet references of lower versions "next to the app" that are causing load failures of higher versions from the SDK.

brandonh-msft added a commit to dotnet/upgrade-assistant that referenced this issue Jun 20, 2022
dotnet/msbuild#7629 updated MSBuild's reference to
`System.Configuration.ConfigurationManager` to the current 6.0.0.0
version. That version is available in the SDK directory and
MSBuildLocator tries to load it but fails. Figuring out why is tracked
as microsoft/MSBuildLocator#159, but this works around the problem by
updating to (and thus redistributing) the same version that MSBuild now
references, which is compatible with older SDKs/MSBuilds as well.

Co-authored-by: Brandon H <brandonh-msft@users.noreply.github.com>
@admalledd
Copy link

If I follow correctly, the only real fix for this one is for the Microsoft.Build NuGet package to release a 17.3 version and having the project reference that newer version. Other option is ugly horrible hack of "unload/reload DLLs from the MSBuild/SDK directory if they are newer than the build dep DLLs" which would not recommend :P. I mentioned /asked for status on a updated Nuget for 17.3 on the related issue.

@YuliiaKovalova
Copy link
Contributor

The issue seems to be already addressed.
Feel free to reopen if it is still relevant.

@YuliiaKovalova YuliiaKovalova closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants