Bonjour à vous tous

j'ai une application qui est censé récupérer la lecture d'un data matrix par usb émulation PortCom.
Rien de bien compliqué, me direz vous. Mais la ou cela bloque c'est qu'au moment d'afficher la lecture j'ai l'erreur suivante :

Impossible d'appeler Invoke ou BeginInvoke sur un contrôle tant que le handle de fenêtre n'a pas été créé.

voici mon code :

IHM.vb
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       General.Init_Post()
End Sub
General.vb
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
    Public Shared Sub Init_Post()
        'Lecture du fichier de config
        Dim strConfigFileName As String = IHM.strPathRootConfig & "\Config.ini"
        Dim str_ScannerComPort As String = ""
 
        'Port com pour la douchette
        str_ScannerComPort = Gestion_INI.GetCle(strConfigFileName, "Poste", "ScannerComPort")
 
        'Init comm douchettes
        Douchette.Init_douchettes(str_ScannerComPort)
 
    End Sub
Douchette.vb
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
    'Gestion des ports com pour les douchettes
    Public WithEvents portCom As New System.IO.Ports.SerialPort
 
    Public Function Init_douchettes(ByVal strPort As String) As Boolean
        Try
            'Si le nom est vide -> pas d'ouverture
            If strPort <> "" Then
                If Me.portCom.IsOpen = False Then
                    'Init des parametres
                    portCom.BaudRate = 38400
                    portCom.Parity = IO.Ports.Parity.None
                    portCom.Handshake = IO.Ports.Handshake.None
                    portCom.StopBits = IO.Ports.StopBits.One
                    portCom.PortName = strPort
 
                    'Initialise le buffer
                    portCom.DiscardNull = True
 
                    'Ouverture
                    portCom.Open()
                End If
            End If
        Catch ex As Exception
            MsgBox("Erreur dans la configuration de la douchette." & vbCrLf & ex.Message)
        End Try
    End Function
 
    'Gestion reception code barre douchette
    Public Sub Reception_Data(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles portCom.DataReceived
 
        Dim strTmp As String = ""
 
        Try
            If portCom.ReadBufferSize > 0 Then
 
                'Recupere les donnees
                strTmp = portCom.ReadExisting
 
                'Vide le buffer
                portCom.DiscardInBuffer()
 
                'Affichage de la trame reçu
                TextBox1.Invoke(New AfficheDataReadDeleg(AddressOf AfficheDataRead), New Object() {strTmp})
            End If
        Catch ex As Exception
            MsgBox("Erreur durant la réception" & vbCrLf & vbCrLf & ex.ToString)
        End Try
    End Sub
 
    'Création d'une délégation pour gestion des threads pour l'affichage
    Delegate Sub AfficheDataReadDeleg(ByVal StrTmp As String)
 
    'affichage de la trame reçu
    Public Sub AfficheDataRead(ByVal StrTmp As String)
        TextBox1.Text = StrTmp
    End Sub
Ligne ou j'ai le blocage:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
'Affichage de la trame reçu
 TextBox1.Invoke(New AfficheDataReadDeleg(AddressOf AfficheDataRead), New Object() {strTmp})