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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
FileLoadException: Assembly with same name is already loaded
when multiple Fody-using projects are referenced
#1268
Comments
FileLoadException: Assembly with same name is already loaded
when multiple projects referenceFileLoadException: Assembly with same name is already loaded
when multiple Fody-using projects are referenced
My guess would be that you didn't put the
|
(Un) fortunately I checked that already. Datadog.Trace has this: <PackageReference Include="Fody" Version="6.8.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="InlineIL.Fody" Version="1.8.0" PrivateAssets="All" /> and Datadog.Trace.Coverage.Collector has the same (with the now-updated InlineIL.Fody version): <PackageReference Include="Fody" Version="6.8.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="InlineIL.Fody" Version="1.8.0" PrivateAssets="All" /> |
Well, that would have been an easy explanation. In any case, Fody is trying to load two different versions of InlineIL I suppose, and that doesn't go very well. The build log you posted seems to show the failure happens while building While we probably should improve the error message, understanding the issue would be useful, since the assembly is loaded in a separate Currently, there's a separate load context for each solution directory, so maybe that could be a brittle approach? Note that when you're not using a solution, the project's parent directory is assumed to be the solution directory. |
I think this could explain the issue then, both of these projects are in the same solution directory in our case 馃檪 And they're also in the same parent directory |
You should already be a Patron
We (Datadog) have sponsored Simon through GitHub - hopefully that's sufficient, if not, just let me know 馃檪
Preamble
Where relevant, ensure you are using the current stable versions of the following:
6.8.0
(latest stable)1.8.0
(latest stable) and1.7.4
17.8.3+195e7f5a3
8.0.100
)Describe the issue
We have been using InlineIL.Fody without issue in the Datadog .NET Client library. We recently had to add it to another project. A third project then references those two:
Once we added Fody to the Datadog.Trace.Coverage.Collector project, the Datadog.Trace.Runner has started failing to build, with the following exception from MSBuild.
This was breaking our build- (Public build in Azure Devops).
I subsequently noticed that we were accidentally referencing two different versions of
InlineIL.Fody
. Fixing both projects to use the same assembly seems to have solved the issue, but it still feels like there may be something to investigate here...Minimal Repro
Unfortunately, this appears to be hard to reproduce as it appears to be a race condition. I have not managed to create a minimal repro yet; I can't reproduce with a simplified version of the setup.
Make an effort to fix the bug
For a while I thought that disabling MSBuild node reuse would work (as it seemed to in the PR and test build), but even with
MSBUILDDISABLENODEREUSE=1
we were still seeing failures 馃檨 The only thing that fixed it was ensuring that all dependent projects used the same version ofInlineIL.Fody
The text was updated successfully, but these errors were encountered: