IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

Erreur d'instanciation avec l'API Mega Client


Sujet :

C#

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2014
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2014
    Messages : 2
    Points : 1
    Points
    1
    Par défaut Erreur d'instanciation avec l'API Mega Client
    Bonsoir (ou bonjour, pour le coup),

    Je fais actuellement un programme utilisant la MegaApiClient, afin d'upload et download directement sur un compte Mega.
    Jusqu'à très récemment, cela fonctionnait, c'était très bien. Et puis un beau jour, je reprends le code, je modifie 2-3 trucs et... Oh, ça marche plus !
    Alors je refais un projet vierge, même problème.

    Je reprends carrément le sample qu'on m'avait donné, testé et fiable, sur lequel j'ai plus jamais retravaillé. Rien, plantage aussi, exception TargetInvocationException...
    {"La référence d'objet n'est pas définie à une instance d'un objet."}

    Voici le code de l'exemple (anciennement) fonctionnel :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
     
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
     
    using CG.Web.MegaApiClient;
    using System.Net;
     
    namespace MegaWithAPI
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
     
            private void btnUpload_Click(object sender, EventArgs e)
            {
                MegaApiClient client = new MegaApiClient();
                WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultCredentials;  // Proxy par défaut
     
                client.Login("mon mail", "mon password");
                var nodes = client.GetNodes();
     
                Node root = nodes.Single(n => n.Type == NodeType.Root);
                Node myFolder = client.CreateFolder("Upload", root);
     
                Node myFile = client.Upload("MyFile.ext", myFolder);
            }
        }
    }

    Et voici celui de mon application test, guère différent :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
     
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using CG.Web.MegaApiClient;
     
    namespace hukjiraeuw
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
     
            private void Form1_Load(object sender, EventArgs e)
            {
                try
                {
                    MegaApiClient client = new MegaApiClient();
     
                    client.Login("autre mail", "autre mdp");
                    var nodes = client.GetNodes();
     
                    Node root = nodes.Single(n => n.Type == NodeType.Root);
                }
     
     
                catch (Exception ex)
                {
                    MessageBox.Show("Bah ça y est, encore une fois...\r\n" + ex.Message);
                }
            }
        }
    }

    Dans les deux cas c'est le "var nodes = client.GetNodes();" qui pose le problème de la non-instanciation. Je ne comprends pas.

    En espérant que vous pourrez me répondre, je vous souhaite une bonne soirée.

  2. #2
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2014
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2014
    Messages : 2
    Points : 1
    Points
    1
    Par défaut Précisions
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
     
    -		$exception	{"Une exception a été levée par la cible d'un appel."}	System.Exception {System.Reflection.TargetInvocationException}
    -		[System.Reflection.TargetInvocationException]	{"Une exception a été levée par la cible d'un appel."}	System.Reflection.TargetInvocationException
    +		base	{"Une exception a été levée par la cible d'un appel."}	System.ApplicationException {System.Reflection.TargetInvocationException}
    -		Data	{System.Collections.ListDictionaryInternal}	System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
    -		[System.Collections.ListDictionaryInternal]	{System.Collections.ListDictionaryInternal}	System.Collections.ListDictionaryInternal
    		Count	0	int
    		IsFixedSize	false	bool
    		IsReadOnly	false	bool
    		IsSynchronized	false	bool
    +		Keys	{System.Collections.ListDictionaryInternal.NodeKeyValueCollection}	System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
    		SyncRoot	{object}	object
    +		Values	{System.Collections.ListDictionaryInternal.NodeKeyValueCollection}	System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
    +		Membres non publics		
    +		Affichage des résultats	L'agrandissement de l'affichage des résultats permet d'énumérer IEnumerable	
    		IsFixedSize	false	bool
    		IsReadOnly	false	bool
    +		Keys	{System.Collections.ListDictionaryInternal.NodeKeyValueCollection}	System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
    +		Values	{System.Collections.ListDictionaryInternal.NodeKeyValueCollection}	System.Collections.ICollection {System.Collections.ListDictionaryInternal.NodeKeyValueCollection}
    +		Affichage des résultats	L'agrandissement de l'affichage des résultats permet d'énumérer IEnumerable	
    		HelpLink	null	string
    		HResult	-2146232828	int
    -		InnerException	{"La référence d'objet n'est pas définie à une instance d'un objet."}	System.Exception {System.NullReferenceException}
    +		[System.NullReferenceException]	{"La référence d'objet n'est pas définie à une instance d'un objet."}	System.NullReferenceException
    +		Data	{System.Collections.ListDictionaryInternal}	System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
    		HelpLink	null	string
    		HResult	-2147467261	int
    +		InnerException	null	System.Exception
    		Message	"La référence d'objet n'est pas définie à une instance d'un objet."	string
    		Source	"MegaApiClient"	string
    		StackTrace	"   à CG.Web.MegaApiClient.Node.OnDeserialized(StreamingContext ctx)"	string
    -		TargetSite	{Void OnDeserialized(System.Runtime.Serialization.StreamingContext)}	System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
    +		[System.Reflection.RuntimeMethodInfo]	{Void OnDeserialized(System.Runtime.Serialization.StreamingContext)}	System.Reflection.RuntimeMethodInfo
    +		base	{Void OnDeserialized(System.Runtime.Serialization.StreamingContext)}	System.Reflection.MemberInfo {System.Reflection.RuntimeMethodInfo}
    		Attributes	FamANDAssem | Family | HideBySig	System.Reflection.MethodAttributes
    		CallingConvention	Standard | HasThis	System.Reflection.CallingConventions
    		ContainsGenericParameters	false	bool
    		IsAbstract	false	bool
    		IsAssembly	false	bool
    		IsConstructor	false	bool
    		IsFamily	false	bool
    		IsFamilyAndAssembly	false	bool
    		IsFamilyOrAssembly	false	bool
    		IsFinal	false	bool
    		IsGenericMethod	false	bool
    		IsGenericMethodDefinition	false	bool
    		IsHideBySig	true	bool
    		IsPrivate	false	bool
    		IsPublic	true	bool
    		IsSecurityCritical	true	bool
    		IsSecuritySafeCritical	true	bool
    		IsSecurityTransparent	false	bool
    		IsSpecialName	false	bool
    		IsStatic	false	bool
    		IsVirtual	false	bool
    +		MethodHandle	{System.RuntimeMethodHandle}	System.RuntimeMethodHandle
    		MethodImplementationFlags	IL	System.Reflection.MethodImplAttributes
    +		Membres non publics		
    +		Membres static		
    +		Membres non publics		
    		Message	"Une exception a été levée par la cible d'un appel."	string
    		Source	"mscorlib"	string
    		StackTrace	"   à System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)\r\n   à System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)\r\n   à System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\r\n   à System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)\r\n   à Newtonsoft.Json.Serialization.JsonContract.<>c__DisplayClass1.<CreateSerializationCallback>b__0(Object o, StreamingContext context)\r\n   à Newtonsoft.Json.Serialization.JsonContract.InvokeOnDeserialized(Object o, StreamingContext context)\r\n   à Newtonsoft.Json.Serialization.JsonSerializerInternalReader.OnDeserialized(JsonReader reader, JsonContract contract, Object value)\r\n   à Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\r\n   à Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n   à Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n   à Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)\r\n   à Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)\r\n   à Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n   à Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)\r\n   à Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\r\n   à Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n   à Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n   à Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n   à Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n   à Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)\r\n   à Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)\r\n   à Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)\r\n   à CG.Web.MegaApiClient.MegaApiClient.Request[TResponse](RequestBase request, Object context)\r\n   à CG.Web.MegaApiClient.MegaApiClient.GetNodes()\r\n   à hukjiraeuw.Form1.Form1_Load(Object sender, EventArgs e) dans d:\\Documents\\Prog_Perso\\hukjiraeuw\\Form1.cs:ligne 29"	string
    -		TargetSite	{System.Object InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)}	System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
    +		[System.Reflection.RuntimeMethodInfo]	{System.Object InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)}	System.Reflection.RuntimeMethodInfo
    +		base	{System.Object InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)}	System.Reflection.MemberInfo {System.Reflection.RuntimeMethodInfo}
    		Attributes	Private | FamANDAssem | Static | HideBySig	System.Reflection.MethodAttributes
    		CallingConvention	Standard	System.Reflection.CallingConventions
    		ContainsGenericParameters	false	bool
    		IsAbstract	false	bool
    		IsAssembly	true	bool
    		IsConstructor	false	bool
    		IsFamily	false	bool
    		IsFamilyAndAssembly	false	bool
    		IsFamilyOrAssembly	false	bool
    		IsFinal	false	bool
    		IsGenericMethod	false	bool
    		IsGenericMethodDefinition	false	bool
    		IsHideBySig	true	bool
    		IsPrivate	false	bool
    		IsPublic	false	bool
    		IsSecurityCritical	true	bool
    		IsSecuritySafeCritical	true	bool
    		IsSecurityTransparent	false	bool
    		IsSpecialName	false	bool
    		IsStatic	true	bool
    		IsVirtual	false	bool
    +		MethodHandle	{System.RuntimeMethodHandle}	System.RuntimeMethodHandle
    		MethodImplementationFlags	InternalCall	System.Reflection.MethodImplAttributes
    +		Membres non publics		
    +		Membres static		
    +		Membres non publics
    Pour la précision, je sais pas jusqu'à quel point les détails de l'erreur sont importants et lesquels le sont.

Discussions similaires

  1. Erreur automation "lien avec les clients perdu"
    Par Many31 dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 16/03/2011, 12h01
  2. Réponses: 0
    Dernier message: 07/08/2009, 16h57
  3. developper un client de plusieurs serveur avec l'api corba du jdk1.6
    Par moffale dans le forum API standards et tierces
    Réponses: 0
    Dernier message: 07/08/2009, 16h32
  4. Réponses: 6
    Dernier message: 28/03/2007, 19h40
  5. Erreur avec l'API dom xml
    Par bluemartini dans le forum Langage
    Réponses: 8
    Dernier message: 23/06/2006, 11h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo