封装服务引用 [英] Encapsulating a Service Reference

查看:135
本文介绍了封装服务引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一套所有需要引用一个Web服务控制台应用程序。我有一个类库,其中包含许多的这些应用程序,包括网络服务(其已被添加作为服务参考)的共享的功能。我知道,正确的方法来处理这是复制从类库的App.config中每一个控制台应用程序块,但导致维护问题。我还发现使用的是共享app.config文件,从每个应用程序的配置对它的引用的替代品。这是更好的,但仍然不是很大 - 它仍然涉及手动配置每个新的应用程序,并要求我以确保共享的配置文件是在所有的应用程序都可以访问的地方。

I'm building a set of Console applications which all need to reference a web service. I have a class library which contains much of the shared functionality of these applications, including the web service (which has been added as a service reference). I know that the "correct" way to handle this is to copy the block from the class library's app.config to each console app, but that causes maintenance headaches. I've also found the alternative of using a shared app.config file, with a reference to it from each app's config. That's better, but still not great - it still involves manually configuring each new app, and requires me to make sure the shared config file is in a place that all the apps can access.

我正在寻找的是三种情况之一(以满意度下降的顺序排列):

What I'm looking for is one of three things (in declining order of satisfaction):


  1. 系统的方式来封装整个服务和一切必要对其进行访问,到这是一个从类库中产生的DLL。

  2. 系统的方式来自动复制相关的配置信息到每个控制台应用程序的生成目录(如一个职位-build脚本)。

  3. 为什么没有前两个是可行的解释。 (在这种情况下,我会使用共享的配置去)

任何意见?

推荐答案

花一些时间来处理其它事情后,我又回到了这个问题,并发现了的此处。特龙的回答这个问题的工作只是对我很好,并且是比什么都简单得多。

After taking some time to work on other things, I returned to this issue and found a related question over here. Trond's answer to that question worked just fine for me, and was much simpler than anything else.

这篇关于封装服务引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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