C
C#3w ago
Olsson

Module initializer only running for one assembly

Hi, I have source generator to generate compiled meta data about classes, to register these for a scripting layer in C++. These are stored as a module initializer, but the module initializer won't run when I load assembly
[System.Runtime.CompilerServices.ModuleInitializer]
public static void Register() => StartUpJobManager.RegisterStartUpJob(typeof(ManagedCropoutSampleProject.Interactable.FResourceInfo).Assembly.GetName().Name!, Initialize);
[System.Runtime.CompilerServices.ModuleInitializer]
public static void Register() => StartUpJobManager.RegisterStartUpJob(typeof(ManagedCropoutSampleProject.Interactable.FResourceInfo).Assembly.GetName().Name!, Initialize);
1 Reply
Aaron
Aaron3w ago
the runtime can't know a module initializer exists until the assembly is loaded

Did you find this page helpful?