简体   繁体   English

在同一进程中运行的Windows Service和Cassini-dev之间共享数据

[英]Share data between Windows Service and Cassini-dev running in the same process

I have a Windows Service written in C#. 我有一个用C#编写的Windows服务。 I have recently added CassiniDev to it to allow remote web administration and monitoring of the service. 我最近将CassiniDev添加到了它,以允许远程Web管理和对该服务的监视。 The integration went really well except for my inability to interact with data layer of my Windows Service from hosted ASP.NET pages. 除了无法从托管的ASP.NET页与Windows服务的数据层进行交互之外,该集成进行得非常好。

I have tried putting everything of interest into a common assembly but the debugger shows there are two loaded assemblies with the same name but from different paths. 我尝试将所有感兴趣的组件放入一个通用程序集,但调试器显示有两个加载的程序集具有相同的名称,但来自不同的路径。 Cassini runs ASP.NET off some temp folder so the assembly I am using is really "a different instance" in the address space of the same process. Cassini在某些临时文件夹上运行ASP.NET,因此我正在使用的程序集在同一进程的地址空间中实际上是“不同的实例”。

I am not sure what is going on here. 我不确定这是怎么回事。 Probably some "application domain" separation stuff that I do not understand at this time. 可能是一些我目前不了解的“应用程序域”分离内容。

So with Windows Service and the web server running in the same process, how can I make them interact? 因此,如果Windows Service和Web服务器在同一进程中运行,如何使它们交互? Say I have some status in the Service part that I want to report in the ASP.NET part. 假设我要在ASP.NET部分中报告服务的某些状态。 Any ideas how I could make this happen? 有什么想法可以实现这一目标吗? Shared memory or TCP comes to mind but it sounds like an overkill for purely intra-process communication. 我想到了共享内存或TCP,但这听起来像是纯粹的进程间通信的过大杀伤力。

If security isn't an immediate concern, ie the data isn't highly sensitive and in a controlled environment, then you could have success using Named Pipes . 如果安全不是紧迫的问题,即数据不是高度敏感且处于受控环境中,那么使用命名管道可以成功。 A managed API for processing piping has been implemented as part of the framework, so you don't need to think in native calls. 该框架中已实现了用于管理管道的托管API,因此您无需考虑本地调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM