Bonjour,
je me retrouve à travailler sur du vb.net que je ne connais pas du tout. J'ai une application qui ne fonctionne pas et pour essayer de comprendre pourquoi je dois faire un petit programme test. Celui ci a pour but d'aller chercher des informations dans un petit script xml et de les afficher par la suite en console par exemple.
J'ai essayé de récupérer le programme d'origine et de l'épurer mais je tombe sur une erreur fréquente:

"Une exception non gérée du type 'System.NullReferenceException' s'est produite dans AdvitiumGPN.exe
Informations supplémentaires*: La référence d'objet n'est pas définie à une instance d'un objet."

cette erreur apparait sur cette ligne:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
"GPNpartSymbol = UCase(GPNPartElement.getAttribute("symbol"))"
Voila le code source du fichier vb.net

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
 
 
Module TestModule_V0_0
 
    Dim gLogFile
 
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
 
    Sub writeLog(ByVal Pin_string, Optional ByVal NeedCarriageReturn = True)
        gLogFile.Write(Format(Now, "dd-MMM-yyyy HH:mm:ss") & " | " & Pin_string)
        If NeedCarriageReturn Then gLogFile.writeLine()
 
 
        Console.Write(Format(Now, "dd-MMM-yyyy HH:mm:ss") & " | " & Pin_string)
        If NeedCarriageReturn Then Console.WriteLine()
 
    End Sub
 
    Public Sub Main()
 
        Dim currentDir As String
        Dim strXML As String
        Dim partId As String
 
        Dim GPNpartPrefix
        Dim GPNpartIdent
        Dim GPNpartSymbol
        Dim GPNDOM As MSXML2.DOMDocument40
        Dim partsDOM As MSXML2.DOMDocument40
        Dim partElement As MSXML2.IXMLDOMElement
        Dim propIndiceElement As MSXML2.IXMLDOMElement
        Dim propStatusElement As MSXML2.IXMLDOMElement
        Dim GPNPartElement As MSXML2.IXMLDOMElement
        currentDir = "D:\Datas\eharrault\TEST_DIR\Interface\fromGPN"
 
 
        GPNDOM = New MSXML2.DOMDocument40
        GPNDOM.load(currentDir)
 
        GPNPartElement = GPNDOM.selectSingleNode("PART")
 
        GPNpartSymbol = UCase(GPNPartElement.getAttribute("symbol"))
 
        strXML = "<Part GUID=""OTI;OT01_PARTS;" & partId & """ PartDefGUID=""OTD;OT01_PARTS"">"
        strXML = strXML & "<Props><Prop InternalName=""PREFIXE"" Value=""" & GPNpartPrefix & """/>"
        strXML = strXML & "<Prop InternalName=""IDENT"" Value=""" & GPNpartIdent & """/>"
        strXML = strXML & "<Prop InternalName=""INDICE"" Value=""AA""/>"
        strXML = strXML & "<Prop InternalName=""LABEL"" Value=""" & GPNPartElement.getAttribute("description1") & """/>"
        strXML = strXML & "<Prop InternalName=""LABEL2"" Value=""" & GPNPartElement.getAttribute("description2") & """/>"
        strXML = strXML & "<Prop InternalName=""ISLAST"" Value=""TRUE""/>"
        strXML = strXML & "<Prop InternalName=""EDITNB"" Value=""1""/>"
        strXML = strXML & "<Prop InternalName=""STATE"" Value=""Development""/>"
        strXML = strXML & "<Prop InternalName=""UNIT_MECA"" Value=""" & UCase(GPNPartElement.getAttribute("unit")) & """/>"
        strXML = strXML & "<Prop InternalName=""HASOFS"" Value=""FALSE""/>"
 
    End Sub
 
End Module
et voila celui du script xml:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
<PART symbol="A200485" description1="PCB ACE4000 GPRS"
description2="MBUS PI SMT Parts" classId="AAB"
classDescription="PCB" unit="UN"
creator="garazas">
<ATTRIBUTE name="DESCRIPTION_1" value="MBUS char(38) PI" unit=""/>
<ATTRIBUTE name="DESCRIPTION_2" value="SMT Parts" unit=""/>
</PART>
merci de bien vouloir m'aider je me sens un peu perdu dans ce langage. Si quelqu'un pouvait m'aider à résoudre ce petit programme ce serait très sympathique

merci beaucoup