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

EnC: Hot Reload fails with unhelpful error message (CS7038) when there are multiple references to the same DLL (System.Runtime) #76284

Open
jaredthirsk opened this issue Dec 5, 2024 · 0 comments

Comments

@jaredthirsk
Copy link

jaredthirsk commented Dec 5, 2024

Version Used:

.NET SDK 9.0.100

Host:
  Version:      9.0.0
  Architecture: x64
  Commit:       9d5a6a9aa4

Steps to Reproduce:

  1. Use an older Fody DLL (ReactiveUI.Fody I think version 19.5.41) to mutilate a .NET DLL. (Put [Reactive] attribute on a property.)
  2. It adds System.Runtime version 8.0 to the DLL. There is also already a System.Runtime version 9.0 in the DLL. I suspect this is not supposed to be. (I see two separate references in the DLL using dotPeek.)
  3. Debug with VS2022 preview or use dotnet watch and make a hot reload change.
  4. No matter what the change is, it fails with CS7038.

Diagnostic Id:

error CS7038: Failed to emit module 'Xyz.Core': Changing the version of an assembly reference is not allowed during debugging: 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' changed version to '9.0.0.0'.

Expected Behavior:

Hot reload works.

Actual Behavior:

Hot reload fails with this error:

dotnet watch :x: error CS7038: Failed to emit module 'Xyz.Core': Changing the version of an assembly reference is not allowed during debugging: 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' changed version to '9.0.0.0'.

Suggestions for fix:

  • [Suggestion 1] Detect this scenario: the assembly has v8, v9 references of a DLL before Hot Reload, and the same two versions after, so do not fail with CS7038, because this is inaccurate: no assembly versions of references actually changed.
  • [Suggestion 2] Improve the error message in this scenario: "DLLs are not allowed to have multiple references to the same DLL, with different version numbers. Bad IL exception." (...that's if this is true. I have no idea.)

Note on bigger picture: Hot Reload has a bad reputation for not working a lot of the time, so any time Microsoft can detect problems caused by 3rd parties (i.e. buggy Fody mutilations), it would be great, in order to rehabilitate the Hot Reload reputation. I almost gave up on tracking this down but I'm glad I didn't. Hot Reload is so helpful when it works.

Crossposted:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants