Share via


PSClientError - Classe

Contient des informations sur une exception SOAP pour une méthode PSI.

Hiérarchie d’héritage

System.Object
  Microsoft.Office.Project.Server.Library.PSClientError

Espace de noms :  Microsoft.Office.Project.Server.Library
Assembly :  Microsoft.Office.Project.Server.Library (dans Microsoft.Office.Project.Server.Library.dll)

Syntaxe

'Déclaration
<SerializableAttribute> _
Public Class PSClientError _
    Implements ISerializable
'Utilisation
Dim instance As PSClientError
[SerializableAttribute]
public class PSClientError : ISerializable

Remarques

Pour obtenir une liste de toutes les erreurs qui se produisent si vous obtenez une exception quand vous appelez une méthode PSI, transmettez l'objet SoapException au constructeur de classe Microsoft.Office.Project.Server.Library.PSClientError . Vous pouvez ensuite utiliser GetAllErrors pour stocker les informations d'erreur dans un tableau de PSErrorInfo et énumérer les erreurs, comme dans l'exemple suivant.

Notes

L'objet PSErrorInfo ne peut pas inclure toutes les informations dont vous avez besoin. Par exemple, si vous utilisez Resource.CheckOutResources où certaines des ressources sont déjà extraits, PSErrorInfo indique la raison de l'échec de chaque ressource qui ne peut pas être extrait, mais n'inclut pas le nom de la ressource ou le GUID. Pour savoir comment obtenir plus d'informations, consultez la rubrique CheckOutResources.

Exemples

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Services.Protocols;
using System.Windows.Forms;
using PSLibrary = Microsoft.Office.Project.Server.Library;
. . .
try
{
    /* call a PSI method */
}
catch (SoapException ex)
{
    string errAttributeName;
    string errAttribute;
    string errMess = "".PadRight(30, '=') + "\r\n" + "Error: " + "\r\n";

    PSLibrary.PSClientError error = new PSLibrary.PSClientError(ex);
    PSLibrary.PSErrorInfo[] errors = error.GetAllErrors();
    PSLibrary.PSErrorInfo thisError;

    for (int i = 0; i < errors.Length; i++)
    {
        thisError = errors[i];
        errMess += "\n" + ex.Message.ToString() + "\r\n";
        errMess += "".PadRight(30, '=') + "\r\nPSCLientError Output:\r\n \r\n";
        errMess += thisError.ErrId.ToString() + "\n";

        for (int j = 0; j < thisError.ErrorAttributes.Length; j++)
        {
            errAttributeName = thisError.ErrorAttributeNames()[j];
            errAttribute = thisError.ErrorAttributes[j];
            errMess += "\r\n\t" + errAttributeName +
                       ": " + errAttribute;
        }
        errMess += "\r\n".PadRight(30, '=');
    }
    MessageBox.Show(errMess, "Error", MessageBoxButtons.OK,
        MessageBoxIcon.Error);
}

Cohérence de thread

Tous les membres statique (Partagé dans Visual Basic)s publics de ce type sont thread-safe. Cela n’est pas garanti pour les membres d’instance.

Voir aussi

Référence

PSClientError - Membres

Microsoft.Office.Project.Server.Library - Espace de noms

CheckOutResources

Autres ressources

Procédure : se connecter à Project Server par programmation

Codes d’erreur de Project Server 2013