PeerCollaboration.RegisterApplication Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Regista o especificado PeerApplication para uma sessão de colaboração com o par chamador.
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)
Parâmetros
- application
- PeerApplication
Para o PeerApplication qual registar o par chamador dentro do âmbito associado (global, local e link-local).
O tipo de registo a realizar. A aplicação pode estar registada apenas para o par chamador ou para todos os pares que utilizam a máquina.
- Atributos
Exceções
A Path propriedade sobre o PeerApplication objeto passado para
applicationénull.A instância de aplicação peer fornecida tem o mesmo valor globalmente único Id que uma aplicação já registada. O registo existente deve ser desregistado antes de uma nova candidatura poder ser registada com o identificador fornecido.
Os application parâmetros e type não podem ser null. Ambos os parâmetros devem ser especificados.
O parâmetro de tipo não está definido para um valor conhecido na PeerApplicationRegistrationType enumeração.
A RegisterApplication(PeerApplication, PeerApplicationRegistrationType) operação não pode ser concluída até que o interlocutor tenha assinado na infraestrutura.
Exemplos
O seguinte exemplo de código ilustra como registar uma aplicação na infraestrutura de Colaboração:
// 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;
}
Observações
O par chamador é obrigado a iniciar sessão na infraestrutura de colaboração entre pares com o SignIn método antes de chamar este método.
O acesso a este método requer um PermissionState de Unrestricted. Este estado é criado quando a Peer sessão de colaboração começa.