Bonjour,

j'ai sur une interface "IHM" avec un bouton.
Lors de l'appui sur le bouton j'appel un Function dans un Module.
Mais j'ai une exception qui monte lors de l'exécution de ce code :
L'exception System.BadImageFormatException n'a pas été gérée
Message="Jeton non valide."
Source="Projet"
StackTrace:
à Projet.Gestion_Txt.EffacementFait(String stFichier1, String stFichier2)
à Projet.IHM.Button2_Click(Object sender, EventArgs e) dans \IHM.vb:ligne 476
à System.Windows.Forms.Control.OnClick(EventArgs e)
à System.Windows.Forms.Button.OnClick(EventArgs e)
à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
à System.Windows.Forms.Control.WndProc(Message& m)
à System.Windows.Forms.ButtonBase.WndProc(Message& m)
à System.Windows.Forms.Button.WndProc(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
à System.Windows.Forms.Application.Run(ApplicationContext context)
à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
à Projet.My.MyApplication.Main(String[] Args) dans 17d14f5c-a337-4978-8281-53493378c1071.vb:ligne 81
à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()
Le main :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Gestion_Txt.EffacementFait("", "")
    End Sub
Cela plante sur Gestion_Txt sans entrer dans la function

Le Module :
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
Imports System.IO
Imports System.IO.File
 
Module Gestion_Txt
    'Effacement déjà réalisés
    Public Function EffacementFait(ByVal stFichier1 As String, ByVal stFichier2 As String) As Boolean
 
        Dim list_Lines_1 As New List(Of Object)(LectureFichier(stFichier1))
        Dim list_Lines_2 As New List(Of Object)(LectureFichier(stFichier2))
 
        For i As Integer = 0 To list_Lines_1.Count - 1
            For j As Integer = 0 To list_Lines_2.Count - 1
                If list_Lines_1(i).Contains(list_Lines_2(j)) Then
                    list_Lines_1.RemoveAt(i)
                End If
            Next
        Next
 
        WriteAllLines(stFichier1, list_Lines_1.ToArray)
 
    End Function
 
End Module