Skip to content

Conversation

Saancreed
Copy link
Member

When building project A that references project B, and project A targets net8.0 while B targets net6.0, attempting to load all the external references into a single MetadataLoadContext explodes horribly with exceptions like

The assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' has already loaded been loaded into this MetadataLoadContext.
At
   at System.Reflection.MetadataLoadContext.LoadFromStreamCore(Stream peStream)
   at System.Reflection.MetadataLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.PathAssemblyResolver.Resolve(MetadataLoadContext context, AssemblyName assemblyName)
   at System.Reflection.MetadataLoadContext.TryFindAssemblyByCallingResolveHandler(RoAssemblyName refName)
   at System.Reflection.MetadataLoadContext.ResolveToAssemblyOrExceptionAssembly(RoAssemblyName refName)
   at System.Reflection.MetadataLoadContext.TryResolveAssembly(RoAssemblyName refName, Exception& e)
   at System.Reflection.MetadataLoadContext.TryGetDefaultCoreAssembly(Exception& e)
   at System.Reflection.MetadataLoadContext.TryGetCoreAssembly(String coreAssemblyName, Exception& e)
   at System.Reflection.TypeLoading.CoreTypes..ctor(MetadataLoadContext loader, String coreAssemblyName)
   at System.Reflection.MetadataLoadContext..ctor(MetadataAssemblyResolver resolver, String coreAssemblyName)
   at LeanCode.ContractsGenerator.Compilation.ContractsCompiler.TryLoadEmbeddedContracts(IReadOnlyCollection`1 compilations) in /home/runner/work/contractsgenerator/contractsgenerator/src/LeanCode.ContractsGenerator/Compilation/ContractsCompiler.cs:line 144
   at LeanCode.ContractsGenerator.Compilation.ContractsCompiler.CompileProjectsAsync(IEnumerable`1 projectPaths, ImmutableDictionary`2 properties) in /home/runner/work/contractsgenerator/contractsgenerator/src/LeanCode.ContractsGenerator/Compilation/ContractsCompiler.cs:line 60
   at LeanCode.ContractsGenerator.Program.HandleProjectAsync(ProjectOptions p) in /home/runner/work/contractsgenerator/contractsgenerator/src/LeanCode.ContractsGenerator/Program.cs:line 175
   at LeanCode.ContractsGenerator.Program.Main(String[] args) in /home/runner/work/contractsgenerator/contractsgenerator/src/LeanCode.ContractsGenerator/Program.cs:line 115

Copy link

@Patonymous Patonymous left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and seems to be working

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

Successfully merging this pull request may close these issues.

2 participants