如何在 VS2022 中将 C# 的 gcAllowVeryLargeObjects 设置为 true **而不**使用 App.config 文件?

发布于 01-21 01:33 字数 481 浏览 2 评论 0原文

我希望能够通过编程(或至少使用项目属性)设置gcalloverylargeobjects true。我知道我可以使用app.config文件,但这非常丑陋,因为它需要为主可执行文件创建一个单独的文件,然后需要使用可执行文件将其传递。

我已经尝试了两个环境。getEnvironMentVariable(“ gcallowverylargeobjects”)emoverition.getenvironmentvariable(“ complus_gcallow verylylargeobjects”),即使我没有打印出任何东西,使用配置文件将gcolalyverylargeobject设置为true。

如果那不起作用,我不希望emoverunt.setenvironmentvariable()也可以使用,并且可以肯定的是。

我对VS2022的项目属性有很好的了解,那里也没有什么可见的。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

机场等船2025-01-28 01:33:45

但您可以解决它:

  1. 将 app.config 设为嵌入式资源或类似资源。
  2. 启动时检查文件是否存在。
  3. 如果没有,则读取资源并写入文件。
  4. 让应用程序自行重新启动。

It isn't possible.

But you can workaround it:

  1. Make the app.config an embedded resource or similar.
  2. At startup, check if the file exists.
  3. If it doesn't, read the resource and write the file.
  4. Let the app restart itself.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文