如何找到Roku IP+;VB.NET中使用SSDP搜索的网络端口
我试图在我的网络上找到我的Roku TV,显然它需要一些SSDP发现,但是,我无法使用任何Nuget库搜索我的设备 我偶然发现并通过Visual Studio 2017社区版为Visual Studio(VB.NET)安装了Nuget软件包。但是,我找不到任何关于如何使用它的文档 任何建议都会有帮助 解决方案: 我找到了一个解决方案,但不是使用ssdpradar,而是。在项目中添加金块后,您可以使用以下代码行获取所有设备,然后从该列表中查找Roku位置(ip+端口)如何找到Roku IP+;VB.NET中使用SSDP搜索的网络端口,vb.net,roku,ssdp,Vb.net,Roku,Ssdp,我试图在我的网络上找到我的Roku TV,显然它需要一些SSDP发现,但是,我无法使用任何Nuget库搜索我的设备 我偶然发现并通过Visual Studio 2017社区版为Visual Studio(VB.NET)安装了Nuget软件包。但是,我找不到任何关于如何使用它的文档 任何建议都会有帮助 解决方案: 我找到了一个解决方案,但不是使用ssdpradar,而是。在项目中添加金块后,您可以使用以下代码行获取所有设备,然后从该列表中查找Roku位置(ip+端口) Imports Rssdp
Imports Rssdp
For Each founddevice As DiscoveredSsdpDevice In founddevices.Result
If founddevice.Usn.Contains("roku:ecp") Then
Rokulocation = founddevice.DescriptionLocation.ToString()
Exit For
End If
Next
我最近成功地使用了一个名为。它是用C#编写的,但您可以将其作为项目加载到解决方案中,并从VB.NET中引用它 这大致就是我使用它的方式:
Imports RokuDotNet.Client
Public Class Form1
Private _discoveryClient As RokuDeviceDiscoveryClient
Public Sub New()
_discoveryClient = New RokuDeviceDiscoveryClient
AddHandler _discoveryClient.DeviceDiscovered, AddressOf DiscoveryHandler
End Sub
Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
_discoveryClient.DiscoverDevicesAsync()
End Sub
Private Async Sub DiscoveryHandler(sender As Object, e As DeviceDiscoveredEventArgs)
If InvokeRequired Then
BeginInvoke(New Action(Sub() DiscoveryHandler(sender, e)))
Return
End If
' Get the display name for the device (if the user entered one when setting it up)
Dim deviceInfo = Await e.Device.Query.GetDeviceInfoAsync
Dim name = deviceInfo.UserDeviceName
If String.IsNullOrEmpty(name) Then
name = deviceInfo.ModelName
End If
AddDevice(e.Device, name)
End Sub
Private Sub AddDevice(device As RokuDevice, name As String)
' Your code here
End Sub
End Class
您可能希望在该异步函数中的wait周围添加try/catch,以便在出现网络问题时显示错误。谢谢@libertyerne的回答。我会尝试并更新帖子。我尝试过这个方法,但没有成功。它说组件构建与我的框架不兼容@自由人