.NET WCF ServiceHost - 启动参数

发布于 2024-08-14 12:41:31 字数 360 浏览 2 评论 0原文

我正在使用 WCF 创建一个远程对象。这是我如何创建远程对象的片段...

ServiceHost service_host = new ServiceHost(typeof(MyObject), new Uri[] { new Uri("net.pipe://localhost") });
service_host.AddServiceEndpoint(typeof(IMyServer), new NetNamedPipeBinding(), "MyServer");
service_host.Open();
return service_host;

有没有办法存储一些在实例化远程对象时可用的变量?我不想控制客户的一切。这可能吗?

I am creating a remotable object using WCF. This is a snipped of how I create the remotable object ...

ServiceHost service_host = new ServiceHost(typeof(MyObject), new Uri[] { new Uri("net.pipe://localhost") });
service_host.AddServiceEndpoint(typeof(IMyServer), new NetNamedPipeBinding(), "MyServer");
service_host.Open();
return service_host;

Is there a way to store some variables which are available when the remotable object is instantiated? I would prefer not to control EVERYTHING from the client. Is this possible?

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

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

发布评论

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

评论(1

ぺ禁宫浮华殁 2024-08-21 12:41:31

也许我不明白这个问题,但我想你的服务托管在服务器进程中,例如 Windows 服务或控制台应用程序。您的远程对象可以访问主机进程的应用程序配置设置。你为什么不把你的变量放在那里呢?

Maybe I don't understand the question, but your service is hosted in server process, I'd image, such as a Windows service, or a console app. Your remotable object has access to the application configuration setting of the host process. Why don't you put your variables there?

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