如何存储 WCF 服务的自定义设置?

发布于 2024-08-13 07:11:32 字数 118 浏览 7 评论 0原文

  1. 人们说库不应该有配置文件。
  2. 我无法从其主机将参数传递给我的 WCF 服务类(但我可以从客户端)。
  3. 我不想将配置存储在客户端上。
  4. 我应该怎么办?
  1. People says that libraries shouldn't have configuration files.
  2. I can't pass arguments to my WCF service class from its host (but I can from the client).
  3. I don't want to store the configuration on the client.
  4. What should I do?

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

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

发布评论

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

评论(2

心的憧憬 2024-08-20 07:11:33

如果我正确地处理这个问题,我不会……

第一点完全是武断的,听起来有点法西斯主义,或者如果你来自英国的话就有点大胆。许多不同类型的库都附带配置文件。你还会采取什么其他方式呢?如果您没有配置它,它会如何工作,这就是 .NET 配置模型的构建基础。

人们需要停止关注架构爱好者、P&P 机制和编程纯粹主义者,他们经常基于一些最好的或次要的设计原则采取极端的观点,最重要的是说你应该这样做和那样做。

从纯粹的技术角度来看,如果您想隐藏配置文件,请对其进行加密。如果您不想这样做,但希望将它们暴露给授权用户,则可以使用受保护的存储。

鲍勃.

I don't if i'm approaching this question properly...

The first point is totally arbitary, and sounds a bit fascist, or bolshie if you come from the Uk. Many different types of libraries come with configuration file. What other way would you do it? How would it work if you didn't have configure it, which is what .NET configuration model is built on.

Folk need to stop focusing on architecture buffs, P&P mechanics and programming purists, who often take extreme views based on some best, or minor design principles, above all else saying you should do this and do that.

On a purley technical footing, if your wanting to hide your configuration file, encrypt them. If you don't want to do that, but want them exposed to authorized users, then use protected storage.

Bob.

浅忆 2024-08-20 07:11:32

你在问什么?您是在谈论服务(服务器端)还是客户端的设置?

为什么不能像其他应用程序一样使用客户端配置文件?这是内置的、首选的做事方式 - 为什么坚持不使用它?

再说一遍:你到底想问什么?或者说你真正想要解决的问题是什么?

  • 对于服务(服务器端):将您的绑定、行为、服务端点等存储在 web.config(如果托管在 IIS 中)或服务主机的 app.config(如果是 NT 服务或控制台应用程序)中)

  • 对于客户端:将您的配置存储在使用您的库的主应用程序的 app.config 中。如果需要,您可以提供现成的“client.config”和“bindings.config”文件,然后只需添加

    ;
       <绑定configSource =“绑定.config”/>
       
    
    

到客户端应用程序的 app.config - 没有比这更容易的了,真的!

What are you asking? Are you talking about settings for the service (the server side), or the client?

Why can't you just use client-side config files like you do for other apps? This is the built-in, preferred way of doing things - why insist on not using it??

So again: what is it really that you're asking? Or what problem is it, that you're trying to solve, really?

  • for a service (server-side): store your bindings, behaviors, service endpoints etc. in the web.config (if hosting in IIS) or in the app.config of your service host (if NT Service or console app)

  • for a client: store your configuration in the main app's app.config that uses your library. If you want to, you can provide ready-made "client.config" and "bindings.config" files and then just simply add

    <system.serviceModel>
       <bindings configSource="bindings.config" />
       <client configSource="client.config" />
    </system.serviceModel>
    

to your client app's app.config - doesn't get much easier than that, really!

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