PeerCollaboration.RegisterApplication メソッド

定義

呼び出し元のピアとのグループ作業セッションのために指定した PeerApplication を登録します。

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)

パラメーター

application
PeerApplication

関連付けられたスコープ内 (グローバル、ローカル、およびリンク ローカル) の呼び出し元ピアを登録するための PeerApplication

type
PeerApplicationRegistrationType

実行する登録の種類。 アプリケーションは、呼び出し元のピアだけに登録することも、またはコンピューターを使用するすべてのピアに登録することもできます。

属性

例外

  • Pathに渡されるapplicationオブジェクトの PeerApplication プロパティは ですnull

  • 指定された Peer Application のインスタンスには、既に登録されているアプリケーションと同じグローバル一意識別子 Id があります。 指定した識別子で新しいアプリケーションを登録する前に、既存の登録を解除する必要があります。

application パラメーターと type パラメーターを null にすることはできません。 両方のパラメーターを指定する必要があります。

type パラメーターが、PeerApplicationRegistrationType 列挙体の既知の値に設定されていません。

呼び出し元がインフラストラクチャにサインインするまではRegisterApplication(PeerApplication, PeerApplicationRegistrationType) 操作を完了できません。

次のコード例は、コラボレーション インフラストラクチャにアプリケーションを登録する方法を示しています。

// 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;
}

注釈

呼び出し元のピアは、このメソッドを呼び出す前に、 メソッドを使用 SignIn してピア コラボレーション インフラストラクチャにサインインする必要があります。

このメソッドにアクセスするには、 の UnrestrictedPermissionState必要です。 この状態は、コラボレーション セッションの開始時に Peer 作成されます。

適用対象