如果app.config中的DLL应在"主要配置和QUOT; ...我们该怎么办,在DLL中WCF参考? [英] If app.config for a DLL should be in the "main config"… what do we do with WCF References in DLLs?

查看:147
本文介绍了如果app.config中的DLL应在"主要配置和QUOT; ...我们该怎么办,在DLL中WCF参考?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这是相当简单的,但是从我所看到的......你只能使用某种Windows工作流的,包括另一个配置成另一种(我拒绝这样做)。

Ok, this is rather simple, but from what I've seen… you can only use some sort of Windows Workflow to include another config into another (which I refuse to do).

这里的交易:

MAINAPP.EXE引用了一个假想的LIBRARY.DLL。

MAINAPP.EXE References an hypothetical LIBRARY.DLL.

MAINAPP.EXE有它自己的MAINAPP.EXE.config

MAINAPP.EXE has its own MAINAPP.EXE.config.

如果您添加配置价值,以LIBRARY.DLL(从而在LIBRARY.DLL项目中的app.config),这些值的没有可用在运行时,即使你复制的应用程序的的.config到LIBRARY.DLL.config正道生成后的的。

If you add "config values" to LIBRARY.DLL (thereby creating an app.config in LIBRARY.DLL project), those values are not available at runtime even if you copy app.config into LIBRARY.DLL.config to the right path post-build.

的原因上面,即使引用的库将从mainapp.exe配置读取。

The reason for the above is that even referenced libraries will read from the "mainapp.exe" config.

到目前为止好。现在,当你添加一个WCF服务参考,Visual Studio创建或填充你的app.config的绑定/端点/等;但是这添加到您添加参考的配置项目;因此,你的Library.DLL.prj结束了一个不错的的app.config是的不能正常工作的,因为它永远不会被读取,甚至也没有复制到输出目录。现在,你可能会认为你可以右键单击该的app.config并设置复制总是为真。算了吧。这并不做任何事情。 (你可以谷歌的那一个)。

So far "so good". Now, when you add a WCF Service reference, visual studio creates or populates your app.config with the bindings/endpoints/etc.; but that's added to the project where you added the reference's config; hence, your Library.DLL.prj ends up with a nice app.config that doesn't work because it never gets read, nor even copied to the output directory. Now you may think that you can right click that app.config and set "copy always" to true. Forget it. That doesn't do anything. (You can google for that one).

因此​​,考虑到上述怪异的场景,怎么是一个普通的VS2008开发与.NET 3.5的项目要管理他补充说WCF服务引用他的业务层的dll工作?那是开发商应该复制和粘贴在没用的app.config中所有的整段在他的DLL到Mainapp.exe.config文件的每次有一个在服务和每一次的变化他补充道/删除一个的?

So, given the above weird scenario, how is a regular VS2008 developer working with a .NET 3.5 project going to manage the WCF service references he adds to his Business Layer dll? Is that developer supposed to COPY and PASTE all the whole section from the useless app.config in his DLL to the Mainapp.exe.config file each time there's a change in the services or each time he adds/removes one ?

推荐答案

是的。复制和粘贴就是答案。这是不是一个伟大的答案,但它的答案,这已自1天.NET 1.0的AppSettings。

Yes. Copy and paste is the answer. It's not a great answer, but it's the answer, and it has been since day 1 in .NET 1.0 with AppSettings.

这篇关于如果app.config中的DLL应在"主要配置和QUOT; ...我们该怎么办,在DLL中WCF参考?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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