.NET WCF ServiceHost - 启动参数
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许我不明白这个问题,但我想你的服务托管在服务器进程中,例如 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?