0

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

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

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

4

1 回答 1

1

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(....).

于 2011-02-28T13:23:42.997 回答