使用服务跨机器进行C#通信 [英] C# communication across machines using services

查看:90
本文介绍了使用服务跨机器进行C#通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在努力在服务器之间同步文件.我创建了Windows服务,该服务实现了FileSystemWatcher .net对象,该对象可用来监视本地文件夹路径并在创建或删除,重命名或更改事件的文件或文件夹时进行更改,并基于这些事件采取措施.

就我而言,我将更改复制到其他文件夹,要将源文件夹内容同步到该文件夹​​.

我通过创建两个Windows服务并指向本地文件夹路径并同步到其他文件夹来启用两种同步:例如service1监视c:watch1并同步到c:watch2.
service2监视c:watch2并同步到c:watch1.这样,任一侧的更改都将复制到另一侧.

现在,我想在两台不同的计算机上安装服务,并在计算机之间复制更改.

我不知道两个Windows服务相互通信的方法.可能的解决方案是WCF双工服务或使用Microsoft同步框架.

我尝试了WCF双工服务,但遇到以下问题.它需要以管理员身份在Windows XP机器下运行(我将同时在XP或Windows服务器机器上运行).我尝试通过谷歌搜索解决方案以允许非管理员用户拥有双工服务,但发现我需要执行以下操作:
http://msdn.microsoft.com/en-us/library/ms733768.aspx [ ^ ]

这是用于配置名称空间保留的语法: http://msdn.microsoft.com/en-us/library /ms733768.aspx [ ^ ]

有人可以帮我语法吗?

另外,我正计划对MS Sync框架进行原型设计,但不知道它用于在服务器之间进行通信的端口是什么?它使用什么网络技术来建立通信.我工作的公司在服务器之间如何通信方面有严格的限制,需要开发一些无需管理员权限即可工作的产品.

我需要尽快提出这一建议,并需要紧急建议:

谢谢

Hi,

I am working on to sync files between servers. I have created windows service which implements FileSystemWatcher .net object which allows one to monitor local folder path and get changes as files or folders get created, deleted, renamed or changed events and take action based on them.

In my case, I am replicating the changes to other folder where I want to sync the source folder content to.

I have enabled two way syncing by creating two windows services and pointing to local folder path and syncing to other: e.g service1 watches c:watch1 and sync to c:watch2.
service2 watches c:watch2 and sync to c:watch1. This way changes on either side is replicated to other side.

Now, I want to install the service on two different machine and replicate the changes across machine.

I don''t know a way for two windows services to talk to each other. Possible solutions would be WCF duplex service or use a Microsoft sync framework.

I tried WCF duplex service but encountered following problem. It needs to run as an admin under windows xp machine(i am going to run on both xp or windows server machines). I tried to google the solution to allow non-admin user to have duplex service and found out that I need to do following:
http://msdn.microsoft.com/en-us/library/ms733768.aspx[^]

this is the syntax for configuring namespace reservation: http://msdn.microsoft.com/en-us/library/ms733768.aspx[^]

can someone help me with the syntax?

Also, I am planning to prototype the MS Sync framework but don''t know which port does it use to communicate between server? What networking technologies does it use to establish the communication. The company that I work for has strict limitation on how servers talk to each other and need to develop something that will work without admin rights.

I need to deliver this asap and need urgent suggestions:

Thanks

推荐答案

MS Sync框架针对该用例提供了示例,请首先检查这些示例,因为它们可以直接使用.
MS Sync framework has samples for this usecase, check the samples first, as it is ready to go as is.


我写了一篇文章,说明了这一点.

同步-文件夹同步应用程序 [
I wrote an article that kinda does that.

Synchronicity - A Folder Synchronizing Application[^]


这篇关于使用服务跨机器进行C#通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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