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

Fix netstandard runtime error by installing mono-devel #20

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Jan 5, 2024

Problem

# mono /usr/local/bin/KSPMMCfgValidator.exe

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'KSPMMCfgValidator.KSPMMCfgValidator' threw an exception. ---> System.BadImageFormatException: Could not resolve field token 0x0400000a, due to: Could not load type of field 'KSPMMCfgValidator.KSPMMCfgValidator+<>c:<>9__1_1' (1) due to: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. assembly:/usr/local/bin/KSPMMCfgValidator.exe type:<>c member:(null)
   --- End of inner exception stack trace ---
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'KSPMMCfgValidator.KSPMMCfgValidator' threw an exception. ---> System.BadImageFormatException: Could not resolve field token 0x0400000a, due to: Could not load type of field 'KSPMMCfgValidator.KSPMMCfgValidator+<>c:<>9__1_1' (1) due to: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. assembly:/usr/local/bin/KSPMMCfgValidator.exe type:<>c member:(null)
   --- End of inner exception stack trace ---

Cause

Mysteries of .NET and Mono. The core error message Could not load file or assembly 'netstandard, Version=2.0.0.0 is essentially completely meaningless in terms of pointing toward a specific problem, so we have to fall back to trial and error.

Installing mono-complete fixed it, so I dug into its dependencies, and found that if I installed all of them except for mono-devel and mono-roslyn, the problem still happened, but if I installed those two packages, it was fixed. This should not happen; dev/compiler tools should not be needed to run an app that's already compiled, but that's where the evidence is leading us.

Changes

Now the Dockerfile installs mono-devel and mono-roslyn, which unfortunately pulls in most of the Mono cruft we were trying to trim in #18. But there appears to be no other way to get Mono to work here.

REPOSITORY                         TAG       IMAGE ID       CREATED             SIZE
kspckan/kspmmcfgvalidator          latest    b235ab1106a1   20 hours ago        197MB
cfgvalidator_test                  latest    ddda9bf1fa99   57 seconds ago      541MB

Fixes #19.

@HebaruSan HebaruSan added the bug Something isn't working label Jan 5, 2024
@HebaruSan HebaruSan merged commit 786ecaa into KSP-CKAN:master Jan 5, 2024
1 check passed
@HebaruSan HebaruSan deleted the fix/netstandard-dep-err branch January 5, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: KSPMMCfgValidator fails to load log4net or a dependency
1 participant