动态更改可执行文件的资源

发布于 10-19 08:07 字数 268 浏览 5 评论 0原文

我有两个 C# 可执行文件:patcher.exe 和 Generator.exe。
现在 patcher.exe 有一个 .Net 资源“config.dat”,但它是空的。

我想要的是generator.exe可以更改(完全覆盖)修补程序的config.dat。这样我们就可以将具有不同配置的修补程序分发给不同的人,而他们实际上并不了解内部处理,也不知道 config.dat 是如何生成的。

那么如何从generator.exe动态更改patcher.exe的.Net资源呢?

I have two C# executables, patcher.exe, and generator.exe.
Now patcher.exe has a .Net resource 'config.dat', and it's empty.

What I want is that generator.exe, can change (completely overwrite) the config.dat of the patcher. This is so that we can distribute patchers with different configuration to different people, without them actually knowing much about the internal processing, nor knowing how the config.dat is generated.

So how to dynamically change the .Net resource of patcher.exe from generator.exe?

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

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

发布评论

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

评论(1

沒落の蓅哖2024-10-26 08:07:32

您确定在运行时编辑嵌入资源就是您想要的吗?因为它需要重新编译。

听起来,您可以通过 app.config 指定您希望在运行时以编程方式使用的应用程序域来实现这种配置灵活性。这可以通过以下方式实现:

AppDomain.CurrentDomain.SetData("CONFIG_FILE", "C:\Path\To\File.config");

或者为用户创建自定义配置部分并将这些包括在内。

最后,您可能还想研究 Satellite 程序集,其中 MSDN 上的示例涉及具有多种不同语言翻译的应用程序。 这里


看来我很抱歉误解了您想要实现的目标。如果我理解正确的话,您似乎想要按照 这篇文章 的思路实现一些目标。有关该方法的信息(诚然,示例不是 C# 代码)是 MSDN,但这给出了逻辑。然后您可以使用 UpdateResource(....)。

You sure editing the embedded resource at runtime is what you're after? As it would require a recompile.

As from the sounds of it you could achieve this configuration flexibility through the app.config by specifying the application domain you wish to use programmatically at runtime. This can be achieved by:

AppDomain.CurrentDomain.SetData("CONFIG_FILE", "C:\Path\To\File.config");

Or by creating custom configuration sections for users and have these included.

Finally you may also want to look into Satellite assemblies with the example on MSDN referring to an application with several different language translations. Here


Right apologies it seems I misunderstood what you were trying to achieve. If I understand correctly it looks like you want to achieve something along the lines of this post. More information on the method (admittedly the sample is not C# code) is on the MSDN, but this gives the logic. You can then use UpdateResource(....).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文