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

RT0999 rears its head again for System.Text.Json 9.0.0.0 #284

Open
Steve-OH opened this issue Nov 22, 2024 · 8 comments
Open

RT0999 rears its head again for System.Text.Json 9.0.0.0 #284

Steve-OH opened this issue Nov 22, 2024 · 8 comments

Comments

@Steve-OH
Copy link

See #206.

.NET 8.0

Reinforced.typings is apparently incompatible with System.Text.Json 9.0.0.0. It reports the following error:

RT0999  Could not load file or assembly 'System.Text.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

The referenced file does exist in the expected .nuget\packages location.

Reverting to System.Text.Json 8.0 fixes the problem, but is not a long term solution, since that version does not support .NET 9.

@smkanadl
Copy link
Contributor

Have you upgraded to the latest 1.6.5 version? Because the older version simply do not support net9.0.

@Steve-OH
Copy link
Author

@smkanadl Yes. In fact, the problem occurred when I upgraded to 1.6.5, because I was doing my periodic package maintenance and upgraded everything else at the same time.

Note that my build target is still .NET 8, so it's not a .NET 9 issue per se.

@smkanadl
Copy link
Contributor

@Steve-OH

Note that my build target is still .NET 8, so it's not a .NET 9 issue per se.

I just checked and I also target net8.0 using the 1.6.5 version of the package and it works fine for me. I change a few things here and there but was not able to reproduce the issue. I also forced STJ to be 9.0.0 while targeting net8.0. That work fine for me.

The only way to break it was to update to net9.0 and force RT to use <RtForceTargetFramework>net8.0</RtForceTargetFramework>. That issued the error for me.

@Steve-OH
Copy link
Author

@smkanadl I can't reproduce the problem in a fresh project, but likewise I can't get it to go away in my real project. I've commented out everything I can in the .csproj file, and it still happens. Of course, if I comment out something that breaks the build, then the error doesn't occur, since it never gets to the point where it can occur.

I will have to do some more experimentation to try to isolate the problem.

@smkanadl
Copy link
Contributor

@Steve-OH If it is a public repo I can have a look, otherwise you have to experiment on your own.

@Steve-OH
Copy link
Author

@smkanadl I was able to isolate the problem: If System.Text.Json 9.0.0 is a dependency, and if the JsonPolymorphic attribute is used, then the error is triggered. See https://github.com/Steve-OH/reinforced-typings-json-polymorphic for a test case.

If you make code changes, the error is not always triggered on a build, but it seems to always trigger on a rebuild of the solution.

@Steve-OH
Copy link
Author

@smkanadl By the way, while fiddling with this I discovered that other 9.0.0 packages can also trigger the error (e.g., Microsoft.Extensions.Logging.Abstractions), although I didn't investigate exactly what causes the error with those.

@smkanadl
Copy link
Contributor

@Steve-OH ah yes, that makes sense. If your net8.0 app is loaded into the net8.0 RT CLI but has a source-generator runtime dependency on net9.0, then the RT CLI would need assembly redirects which it (most likely) doesn't have.

Good thing that I usually never update dependencies on versions greater than the framework version. Otherwise I would have hit the issue also.

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

2 participants