在具有不同配置文件内容的不同计算机上配置DLL的最佳方法 [英] Best approach to Configure DLL in different machines with different config file contents

查看:95
本文介绍了在具有不同配置文件内容的不同计算机上配置DLL的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

如果我有一个DLL,并且具有不同配置文件的不同计算机都使用它,那是最好的方法?我相信,如果某些机器的某些配置文件中未设置某些属性,则可能会出现问题.

例如:

MachineA的myDLL.dll使用以下mySimpleConfig.config:

< configuration>
< xCoord> 0</xCoord>
< yCoord> 0</yCoord>
<颜色>棕色</color>
</configurations>


MachineB的myDLL.dll使用以下myLackingConfig.config:

< configuration>
<颜色>棕色</color>
<背景>白色</background>
</configurations>

myDLL.dll的常规"属性是在MachineA中设置的属性. MachineB的配置文件缺少某些所需的属性,并且还具有myDLL.dll不支持的属性.

到目前为止,我想到的解决方案是:
-创建一个创建.config文件的工具,以便所有使用myDLL.dll的计算机都具有相同的内容.缺点是创建该工具需要花费时间.
-只需为未在配置文件中设置的属性(默认值)设置默认值

我搜索了如何根据配置文件的不同内容加载DLL文件,但似乎没有一个与我的情况相同.

任何帮助都可以.链接将有很大帮助.

谢谢. :)

Hi all,

What is the best approach if I have a DLL and different machines with different configuration files use it? I believe issues may arise specially if some properties are not set in some of the configuration files in some machines.

For example:

MachineA''s myDLL.dll uses mySimpleConfig.config below:

<configurations>
<xCoord> 0 </xCoord>
<yCoord> 0 </yCoord>
<color> brown </color>
</configurations>


MachineB''s myDLL.dll uses myLackingConfig.config below:

<configurations>
<color> brown </color>
<background> white </background>
</configurations>

The "normal" properties of myDLL.dll are the ones set in MachineA. MachineB''s config file lacks some of the properties needed and it also has properties not supported by myDLL.dll.

The solutions I have in mind so far are:
- make a tool that creates the .config file so all the machines using myDLL.dll will have the same contents. Disadvantage is it will take time to create the tool.
- just make default values for properties not set in the config file (the obvious one)

I searched on how to load DLL files based on different contents of config files but none of them seem to have the same situation as mine.

Any help will do. Links will be of great help.

Thanks. :)

推荐答案

这不是解决问题的最佳方法.使用DLL的应用程序应通过对DLL的一些初始化调用来设置这些属性,从而消除了对任何配置文件的需要. DLL不应依赖于正在加载的机器,而应具有足够的灵活性以在必要时提供其功能的子集.
This is not the best way to approach your problem. The application using the DLL should set these properties by some initialisation call into the dll thus eliminating the need for any configuration file. A DLL should not be dependent on the machine it is being loaded on, but should be flexible enough to provide a subset of its features when necessary.


我认为,正如您自己说的那样,最快,最简单的解决方案是为配置文件中没有的属性设置默认值.
I think, as you said yourself, the quickest and easiest solution is having default values for properties which are not in the config file.


这篇关于在具有不同配置文件内容的不同计算机上配置DLL的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆