Reputation: 3656
I have a WPF application created with .Net Framework, however I need to use it to enable / disable the Windows 10 hotspot.
After much searching around, apparently the way to do it is using the NetworkOperatorTetheringManager class.
However, I can't use the Windows.Networking.NetworkOperators or add a reference, presumably because it's part of the UWP SDK and not the standard .NET framework. As I understand it, it would have to be built as a UWP application from the beginning.
Is there any way to do access this functionality?
(I've also come across WlanHostedNetworkStartUsing()
but this appears to be for the now deprecated netsh hostednetwork rather than the Mobile Hotspot)
Upvotes: 0
Views: 853
Reputation: 3656
So what worked for me (as advised on another forum at Microsoft
Install Windows 10 SDK
Add references to
C:\Program Files (x86)\Windows Kits\10\UnionMetadata[version]\Windows.winmd
and
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5\System.Runtime.WindowsRuntime.dll`
Then I could do...
using Windows.Networking.Connectivity;
using Windows.Networking.NetworkOperators;
Upvotes: 0
Reputation: 8681
If you want use UWP API from desktop application that uses .net Framework application or .NET Core 3.x, you just need to install the Microsoft.Windows.SDK.Contracts NuGet package. Then you could use the Windows Runtime API after adding the correct namespace.
More information and detailed explanation here: Call Windows Runtime APIs in desktop apps.
Upvotes: 2