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

Prevent KSPe from initialising itself twice. #51

Closed
Lisias opened this issue May 13, 2023 · 3 comments
Closed

Prevent KSPe from initialising itself twice. #51

Lisias opened this issue May 13, 2023 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Lisias
Copy link
Collaborator

Lisias commented May 13, 2023

KSPe.InstallChecker has a borderline use case that is getting screwed by issue #50 : when the user reinstall KSPe from scratch using the same Release.

This was not happening until https://github.com/net-lisias-ksp/ModularManagement would to be, as this package can be reinstalled updating something else but keeping KSPe the same.

This is harmless on KSP >= 1.8.0 where multiple Assembly loading was short-circuited, but it was undesired before it as things would be loaded on a different AppDomain, taxing all the calls due internal serialisation. See https://learn.microsoft.com/en-us/dotnet/framework/app-domains/how-to-load-assemblies-into-an-application-domain for more information.

With #50, this became a fatal error as since the previous incarnation had already loaded the auxiliary DLLs, the code is barking on it now.

Instrument KSPe to prevent initialising itself if it detects another instance of it in a way that save our sorry arses in KSP < 1.8.0 but do not screw up KSP >= 1.8.0

@Lisias Lisias added the bug Something isn't working label May 13, 2023
@Lisias Lisias added this to the 2.5.3.0 milestone May 13, 2023
@Lisias Lisias self-assigned this May 13, 2023
@Lisias
Copy link
Collaborator Author

Lisias commented May 13, 2023

Implemented on commit 88f3a67 .

It worths to mention that, besides hot deleting DLLs on a live KSP session is usually a bad idea (since this potentially screws up Reflection), on this case it is… relatively safe as I'm not removing every instance of the DLL, as it's happening with ZeroMiniAVC. See sarbian/ModuleManager#177 for details .

When using Reflection, KSP (or Mono?) always pinpoints to the first loaded Assembly, as it appears, and since KSPe.InstallChecker is preserving the first one to be loaded, no harm is done.

@Lisias
Copy link
Collaborator Author

Lisias commented May 13, 2023

Closing it as Fixed.

@Lisias Lisias closed this as completed May 13, 2023
@Lisias Lisias modified the milestones: 2.5.3.0, 2.5.2.1 May 13, 2023
@Lisias
Copy link
Collaborator Author

Lisias commented May 14, 2023

This code was rolled back, it will not reach the mainstream.

Issue #50 implements a better solution.

(screw that - the code will stay)

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

No branches or pull requests

1 participant