简体   繁体   English

内部.net应用程序宣布其位置和版本的良好广播机制?

[英]A good broadcast mechanism for inhouse .net applications to announce their location and version?

I would like to provide a large number of inhouse .net applications with a lightweight way to announce that they are being used. 我想为大量的内部.net应用程序提供一种轻量级的方式来宣布它们正在被使用。 My goal is to keep track of which users might benefit from support check-ins and/or reminders to upgrade. 我的目标是跟踪哪些用户可以从支持签入和/或升级提醒中受益。

This is on an inhouse network. 这是在内部网络上。 There is definitely IP connectivity among all the machines, and probably UDP. 所有机器之间肯定存在IP连接,并且可能还有UDP。 (But probably not multicast.) (但可能不是多播。)

Writing to a known inhouse share or loading a known URL would be possibilities, but I would like to minimize the impact on the application itself as completely as possible, even at the expense of reliability. 可以写入一个已知的内部共享或加载一个已知的URL,但是我想尽最大可能将对应用程序本身的影响最小化,即使是以可靠性为代价。 So I would rather not risk a timeout (for example if I'm accessing some centralized resource and it has disappeared), and ideally I would rather not launch a worker thread either. 因此,我宁愿不冒超时的风险(例如,如果我正在访问某些集中式资源并且该资源已消失),并且理想情况下,我也不愿启动工作线程。

It would also be nice to permit multiple listeners, which is another reason I am thinking about broadcasting rather than invoking a service. 允许多个侦听器也很好,这是我考虑广播而不是调用服务的另一个原因。

Is there some kind of fire-and-forget broadcast mechanism I could use safely and effectively for this? 我是否可以安全有效地使用一劳永逸的广播机制?

There are certainly many options for this, but one that is very easy to implement and meets your criteria is an Asynchronous Web Service call. 当然,有很多选择,但是一个很容易实现并且满足您标准的选择是异步Web服务调用。

This does not require you to start a worker thread (the Framework will do that behind the scenes). 这不需要您启动工作线程(框架将在后台执行此操作)。 Rather than use one of the options outlined in that link to fetch the result, simply ignore the result since it is meaningless to the calling app. 无需使用该链接中概述的选项之一来获取结果,而只需忽略结果,因为它对调用应用程序没有意义。

I did something similar, though not exactly a "braodcast" 我做了类似的事情,尽管不完全是“广播”

I have an in house tool several non-techies in the company use. 我有一个内部工具供公司中的一些非技术人员使用。 I have it check a network share for a specific EXE (the same EXE you would download if you wanted to use it) and compares the version # of that file with the executing assembly. 我让它检查特定EXE的网络共享(如果要使用它,则下载相同的EXE),并将该文件的版本号与正在执行的程序集进行比较。 If the one on the network is newer, alert the user to download the new one. 如果网络上的一个较新,请警告用户下载新的一个。

A lot simpler than trying to set up an auto updater for something that will only be used within the same building as me. 比尝试为仅与我在同一建筑物内使用的东西设置自动更新程序要简单得多。

If upgrading is not an issue (ie there are no cases where using the old version is better), you can do what I did with something similar: 如果升级不是问题(即在任何情况下都不能使用旧版本更好),则可以执行类似的操作:

The application that people actually launch is an updater program, it checks the file version and timestamp on a network share and if a newer version exists, copies it to the program directory. 人们实际启动的应用程序是更新程序,它检查网络共享上的文件版本和时间戳,如果存在较新的版本,则将其复制到程序目录中。 It then runs the program (whether it was updated or not). 然后,它运行该程序(无论是否已更新)。

var current = new FileInfo(local);
var latest = new FileInfo(remote);

if (!current.Exists)
    latest.CopyTo(local);

var currentVersion = FileVersionInfo.GetVersionInfo(local);
var latestVersion = FileVersionInfo.GetVersionInfo(remote);

if (latest.CreationTime > current.CreationTime || latestVersion.FileVersion != currentVersion.FileVersion)
    latest.CopyTo(local, true);

Process.Start(local)

I also have the program itself check to see if the updater needs updating (as the updater can't update itself due to file locks) 我还让程序自己检查更新程序是否需要更新(由于文件锁定,更新程序无法自我更新)

After some experimentation, I have been getting good results using Win32 mailslots . 经过一些试验,使用Win32 mailslots取得了良好的效果。

There is no official managed wrapper, but the functions are simple to use via PInvoke, as demonstrated in examples like this one . 没有正式的托管包装器,但是通过PInvoke可以轻松使用这些功能,如示例所示。

Using a 'domain' mailslot provides a true broadcast mechanism, permitting multiple listeners and no requirement for a well-known server. 使用“域”邮筒提供了一种真正的广播机制,允许多个侦听器,并且不需要知名服务器。

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

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