简体   繁体   English

用.NET编写的Windows服务被VB6应用程序占用

[英]Windows Service written in .NET consumed by VB6 application

This question is a follow up on a previous asked question: link 该问题是对先前询问的问题的跟踪: 链接

I have to develop a Windows Service in .NET/C#. 我必须在.NET / C#中开发Windows服务。 The service must be consumed by an application written in VB6. 该服务必须由用VB6编写的应用程序使用。 The service implements Quartz.NET to handle scheduled tasks and must implement listeners to be able to start functions that are initiated by the VB6 application. 该服务实现Quartz.NET来处理计划的任务,并且必须实现侦听器以能够启动由VB6应用程序启动的功能。

The requirement for the VB6 team is to be able to use Winsock. VB6团队的要求是能够使用Winsock。 Therefor I have to use sockets and listeners. 因此,我必须使用套接字和侦听器。 The problem is that I have no experience with that, I'm more of a WCF guy. 问题是我没有经验,我更像是WCF的家伙。

I'm looking at the TcpListener class now to see if this will fit the requirement. 我现在在看TcpListener类,看这是否符合要求。

My first question: Will the VB6 team be able to consume the service if I implement the TcpListener class, keeping in mind the short comings of using VB6 (such as data structures and binary formatting)? 我的第一个问题:如果实现TcpListener类,VB6团队能够使用该服务,同时牢记使用VB6的缺点(例如数据结构和二进制格式)吗?

My second question: Let's say 3 functions must be available for the VB6 application, and 1 listener is created. 我的第二个问题:假设3个功能对于VB6应用程序必须可用,并且创建了1个侦听器。 What are the best practices for the implementation of this? 实施此最佳做法是什么?

Once again: any advice is much appreciated! 再次:任何建议都将不胜感激!

Passing payloads as XML, textual Key/Value pairs, JSON, or other loose serialization formats can help future-proof your protocol. 将有效负载作为XML,文本键/值对,JSON或其他宽松的序列化格式进行传递可以帮助您对协议进行过时验证。 This allows you to use and even add new optional method arguments to the server end at will. 这使您可以随意在服务器端使用甚至添加新的可选方法参数。

In addition to a "method" field you can have a "protocol version" field. 除了“方法”字段外,您还可以具有“协议版本”字段。 When a breaking change is made (new required args, changes in existing arg types, etc.) you can use the version number to handle both old and new clients during a transition period - which might span years. 进行重大更改(新的必需arg,现有arg类型的更改等)后,您可以使用版本号在过渡期(可能跨越数年)中同时处理新旧客户端。

As far as providing message framing on top of the TCP stream goes you can use simple EOM delimiters of some sort or a message header containing a binary or text length prefix. 只要在TCP流的顶部提供消息框架,就可以使用某种简单的EOM定界符或包含二进制或文本长度前缀的消息头。

You might also consider Named Pipes. 您可能还会考虑命名管道。 TransactNamedPipe() is fairly easy to call from a VB6 program. 从VB6程序很容易调用TransactNamedPipe() This takes care of the message-boundary issue for you - assuming you want an RPC-style protocol rather than async send/receive. 假设您需要RPC样式的协议,而不是异步发送/接收,这将为您解决消息边界问题。

Or you might go all the way and use MSMQ. 否则,您可能会一直使用MSMQ。 Private machine queues don't require extensive administration. 专用机队列不需要大量管理。 But even though both VB6 and .Net have excellent MSMQ support most devs know little about it. 但是,即使VB6和.Net都具有出色的MSMQ支持,大多数开发人员对此也知之甚少。

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

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