将 Windows 服务类添加到类库
我在 VB.NET 中有一个类库,它为 USB 设备驱动程序提供 NET 信封。
该驱动程序只有一个功能我无法封装在传统类中,但我必须将其放入 Windows 服务中,如下所述: 在应用程序之间共享类属性(字段)
Windows服务工作正常,但现在我的 NET 信封有两个项目:一个是类库,第二个是 Windows 服务,我不喜欢为同一个驱动程序维护两个不同的项目。
将 Windows 服务类添加到普通类库(而不像 vb 教程中所述创建自己的项目)是否是一个好的做法(或者即使可能)? 我知道,无论如何,我应该只为 Windows 服务创建一个单独的设置,但通过这种方式,我可以将包含我的 USB 设备驱动程序的所有类集中在一个项目中。
I have a class library in VB.NET that does a NET-envelope for an USB device driver.
There is only one function of that driver that I could not envelope in a traditional class, but I had to put it in a Windows Service as described here:
Sharing a class property (field) between applications
The Windows Service works fine, but I have now two projects for my NET-envelope: the one with the class library, the second with the windows service and I do not like the idea to maintain two distinct projects for the same driver.
Is it a good practice (or even if possible) to add a windows service class to a normal class library (without creating its own project as described in the vb tutorial)?
I know, in any case I should create a separate setup only for the windows service, but in this way I could have together all the classes that envelope my usb device driver in only one project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这取决于您的项目的规模。用最少的代码完成一件事的简单服务作为单个项目/EXE 就可以了。
调用数据库、构建对象和执行报告的服务如果是多个项目(一个 EXE 和多个支持 DLL)会更好。
这是一个设计决策,而不是代码决策。
I think that it depends on the size of your project. A simple service that does one thing with a minimal amount of code would be fine as a single project/EXE.
A service that calls a database, builds objects, and does reporting would be better as multiple projects (one EXE and several support DLLs).
It's a design decision, not a code decision.