PeerCollaboration.RegisterApplication Methode

Definitie

Registreert de opgegeven PeerApplication voor een samenwerkingssessie met de aanroepende peer.

public:
 static void RegisterApplication(System::Net::PeerToPeer::Collaboration::PeerApplication ^ application, System::Net::PeerToPeer::Collaboration::PeerApplicationRegistrationType type);
[System.Security.SecurityCritical]
public static void RegisterApplication(System.Net.PeerToPeer.Collaboration.PeerApplication application, System.Net.PeerToPeer.Collaboration.PeerApplicationRegistrationType type);
[<System.Security.SecurityCritical>]
static member RegisterApplication : System.Net.PeerToPeer.Collaboration.PeerApplication * System.Net.PeerToPeer.Collaboration.PeerApplicationRegistrationType -> unit
Public Shared Sub RegisterApplication (application As PeerApplication, type As PeerApplicationRegistrationType)

Parameters

application
PeerApplication

De PeerApplication naam waarvoor de aanroepende peer moet worden geregistreerd binnen het gekoppelde bereik (globaal, lokaal en link-local).

type
PeerApplicationRegistrationType

Het type registratie dat moet worden uitgevoerd. De toepassing kan alleen worden geregistreerd voor de aanroepende peer of voor alle peers die gebruikmaken van de computer.

Kenmerken

Uitzonderingen

  • De Path eigenschap van het PeerApplication object waarnaar wordt doorgegeven application , is null.

  • Het opgegeven exemplaar van de peertoepassing heeft hetzelfde wereldwijd uniek Id als een toepassing die al is geregistreerd. De bestaande registratie moet ongedaan worden gemaakt voordat een nieuwe toepassing kan worden geregistreerd met de opgegeven id.

De application en type parameters kunnen niet zijn null. Beide parameters moeten worden opgegeven.

De typeparameter is niet ingesteld op een bekende waarde in de PeerApplicationRegistrationType opsomming.

De RegisterApplication(PeerApplication, PeerApplicationRegistrationType) bewerking kan pas worden voltooid als de aanroeper zich heeft aangemeld bij de infrastructuur.

Voorbeelden

In het volgende codevoorbeeld ziet u hoe u een toepassing registreert bij de samenwerkingsinfrastructuur:

// Registering Notepad.exe as a collab application with a fixed GUID.
// Note: If you're using the application to send invitations,
// the same application with the same GUID must be registered on the remote peer machine.
private static PeerApplication RegisterCollabApp()
{
    PeerApplication application = null;
    string pathToApp = "%SystemRoot%\\notepad.exe";
    Guid appGuid = new Guid(0xAAAAAAAA, 0xFADE, 0xDEAF, 0xBE, 0xEF, 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAE);

    application = new PeerApplication();
    application.Id = appGuid;
    application.Path = pathToApp;
    application.Description = "Peer Collaboration Sample -- notepad.exe";
    application.PeerScope = PeerScope.All;
    application.CommandLineArgs = "n";
    application.Data = ASCIIEncoding.ASCII.GetBytes("Test");

    Console.WriteLine("Attempting to register the application \"notepad.exe\"...");
    try
    {

        PeerApplicationCollection pac = PeerCollaboration.GetLocalRegisteredApplications(PeerApplicationRegistrationType.AllUsers);
        if (pac.Contains(application))
        {
            Console.WriteLine("The application is already registered on the peer.");
        }
        else
        {
            PeerCollaboration.RegisterApplication(application, PeerApplicationRegistrationType.AllUsers);
            Console.WriteLine("Application registration succeeded!");
        }
    }
    catch (ArgumentException argEx)
    {
        Console.WriteLine("The application was previously registered with the Peer Collaboration Infrastructure: {0}.", argEx.Message);
    }
    catch (PeerToPeerException p2pEx)
    {
        Console.WriteLine("The application failed to register with the Peer Collaboration Infrastructure: {0}", p2pEx.Message);
    }
    catch (Exception ex)
    {
        Console.WriteLine("An unexpected exception occurred when trying to register the application: {0}.", ex.Message);
    }
    return application;
}

Opmerkingen

De aanroepende peer is vereist om u aan te melden bij de peer-samenwerkingsinfrastructuur met de SignIn methode voordat u deze methode aanroept.

Voor toegang tot deze methode is een PermissionState van Unrestricted. Deze status wordt gemaakt wanneer de Peer samenwerkingssessie begint.

Van toepassing op