2017-12-09 3 views
0

私はこのような.NET 4.0でコンソールアプリケーションを作成しました:)apnsBroker.Startでエラーが(あり指定された引数が有効な値の範囲外です。 apnsBroker.StartでcreationOptions()

static void Test2(string deviceToken, string message) 
{ 
    try 
    { 

     //Get Certificate 
     var appleCert = System.IO.File.ReadAllBytes("Certificates_moi.p12"); 

     // Configuration (NOTE: .pfx can also be used here) 
     var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Sandbox, appleCert, "vnpt1234"); 

     // Create a new broker 
     var apnsBroker = new ApnsServiceBroker(config); 

     // Wire up events 
     apnsBroker.OnNotificationFailed += (notification, aggregateEx) => 
     { 

      aggregateEx.Handle(ex => 
      { 

       // See what kind of exception it was to further diagnose 
       if (ex is ApnsNotificationException) 
       { 
        var notificationException = (ApnsNotificationException)ex; 

        // Deal with the failed notification 
        var apnsNotification = notificationException.Notification; 
        var statusCode = notificationException.ErrorStatusCode; 
        string desc = "Apple Notification Failed: ID={apnsNotification.Identifier}, Code={statusCode}"; 
        Console.WriteLine(desc); 
        //lblStatus.Text = desc; 
       } 
       else 
       { 
        string desc = "Apple Notification Failed for some unknown reason : {ex.InnerException}"; 
        // Inner exception might hold more useful information like an ApnsConnectionException   
        Console.WriteLine(desc); 
        //lblStatus.Text = desc; 
       } 

       // Mark it as handled 
       return true; 
      }); 
     }; 

     apnsBroker.OnNotificationSucceeded += (notification) => 
     { 
      //lblStatus.Text = "Apple Notification Sent successfully!"; 
      Console.WriteLine("Apple Notification Sent successfully!"); 
     }; 

     var fbs = new FeedbackService(config); 
     fbs.FeedbackReceived += (string devicToken, DateTime timestamp) => 
     { 
      // Remove the deviceToken from your database 
      // timestamp is the time the token was reported as expired 
     }; 

     // Start Proccess 
     apnsBroker.Start(); 

     if (deviceToken != "") 
     { 
      apnsBroker.QueueNotification(new ApnsNotification 
      { 
       DeviceToken = deviceToken, 
       Payload = JObject.Parse(("{\"aps\":{\"badge\":1,\"sound\":\"oven.caf\",\"alert\":\"" + (message + "\"}}"))) 
      }); 
     } 

     apnsBroker.Stop(); 

    } 
    catch (Exception ex) 
    { 

     throw; 
    } 
} 

を。 - $ exception {"指定された引数が有効な値の範囲外です。\ r \ nパラメータ名:creationOptions"} System.Exception {System.ArgumentOutOfRangeException} 誰でも助けてくれますか?

答えて

0

この問題は修正されました。 .NET 4.5を実行している別のマシンに移動すると、うまくいきました。

関連する問題