I want to be able to programmatically (or at least using the Project properties) set gcAllowVeryLargeObjects
to true. I know I can use the App.config file, but this is quite ugly as it needs to create a separate file to the main executable which then needs to be passed around with the executable.
I've experimented with both Environment.GetEnvironmentVariable("gcAllowVeryLargeObjects")
and Environment.GetEnvironmentVariable("COMPlus_gcAllowVeryLargeObjects")
, but it doesn't print out anything, even if I set gcAllowVeryLargeObjects to true using a config file.
If that doesn't work, I don't expect Environment.SetEnvironmentVariable()
to work either, and sure enough, it doesn't.
I've had a good look in the Project properties of VS2022, and there's nothing to be seen there either.
CodePudding user response:
It isn't possible.
But you can workaround it:
- Make the app.config an embedded resource or similar.
- At startup, check if the file exists.
- If it doesn't, read the resource and write the file.
- Let the app restart itself.