Windows Peer Near Me (PNM) API В Windows 10 не работает?

Мы пытаемся использовать Windows PNM API через код.Net, используя следующий пример кода:

using System;
using System.Net.PeerToPeer;
using System.Net.PeerToPeer.Collaboration;

namespace GetPeersNearMe
{
    class Program
    {
        static void Main(string[] args)
        {            
            PeerCollaboration.SignIn(PeerScope.All);

            PeerNearMeCollection peers = null;
            try
            {
                peers = PeerCollaboration.GetPeersNearMe();
                if (peers == null ||
                    peers.Count == 0)
                {
                    Console.WriteLine("There are no peers near me.");
                }
                foreach (PeerNearMe pnm in peers)
                {
                    Console.WriteLine("Getting the peers near me: {0}, nickname {1}, isOnline {2}",
                        pnm.ToString(),
                        pnm.Nickname,
                        pnm.IsOnline);
                }
            }
            catch (PeerToPeerException p2pEx)
            {
                Console.WriteLine("Could not obtain an enumeration of the peers near me: {0}", p2pEx.Message);
            }
            catch (InvalidOperationException ioEx)
            {
                Console.WriteLine("The application is no longer signed into the Peer Collaboration Infrastructure: {0}",
                    ioEx.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unexpected exception caught when trying to enumerate the peers near me: {0}",
                    ex.Message);
            }

        }
    }

И мы продолжаем получать следующее исключение:

System.Net.PeerToPeer.PeerToPeerException was unhandled
  HResult=-2146233088
  Message=Peer collaboration startup failed.
  Source=System.Net
  StackTrace:
       at System.Net.PeerToPeer.Collaboration.CollaborationHelperFunctions.Initialize()
       at System.Net.PeerToPeer.Collaboration.PeerCollaboration.SignIn(PeerScope peerScope)
       at GetPeersNearMe.Program.Main(String[] args) in c:\Program.cs:line 11
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.ComponentModel.Win32Exception
       HResult=-2147467259
       Message=The Windows Peer-to-Peer infrastructure is not licensed to operate on this platform.
       ErrorCode=-2147467259
       NativeErrorCode=-2140995580
       InnerException:

Мы убедились, что следующие службы Windows работают перед тестированием нашего кода:

  • Протокол разрешения имен
  • Группировка одноранговых сетей
  • Менеджер идентичности в одноранговой сети
  • Служба публикации имен машин PNRP

И мы все еще получаем вышеупомянутое исключение. что нам не хватает?

Мы выполняем код на компьютере с Windows 10, и код работает с.Net 4.5.1

0 ответов

Другие вопросы по тегам