PeerCollaboration.RegisterApplication Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Inscrit le spécifié PeerApplication pour une session de collaboration auprès de l’homologue appelant.
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)
Paramètres
- application
- PeerApplication
Pour PeerApplication laquelle inscrire l’homologue appelant dans l’étendue associée (global, local et link-local).
Type d’inscription à effectuer. L’application peut être inscrite uniquement pour l’homologue appelant ou pour tous les homologues utilisant l’ordinateur.
- Attributs
Exceptions
La Path propriété sur l’objet PeerApplication passé
applicationestnull.L’instance d’application homologue fournie a le même niveau global unique Id qu’une application déjà inscrite. L’inscription existante doit être annulée avant qu’une nouvelle application puisse être inscrite auprès de l’identificateur fourni.
Les paramètres et application les type paramètres ne peuvent pas être null. Les deux paramètres doivent être spécifiés.
Le paramètre de type n’est pas défini sur une valeur connue dans l’énumération PeerApplicationRegistrationType .
L’opération RegisterApplication(PeerApplication, PeerApplicationRegistrationType) ne peut pas être terminée tant que l’appelant n’a pas été connecté à l’infrastructure.
Exemples
L’exemple de code suivant montre comment inscrire une application auprès de l’infrastructure collaboration :
// 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;
}
Remarques
L’homologue appelant est requis pour se connecter à l’infrastructure de collaboration homologue avec la SignIn méthode avant d’appeler cette méthode.
L’accès à cette méthode nécessite un PermissionState de Unrestricted. Cet état est créé lorsque la Peer session de collaboration commence.