Application freeze when I use an external library

79 views Asked by At

My application contains a main file allowing to generate an executable using Codedom. This executable is make from my file Source.vb.

I would like to use an external library in the latter. In particular, this is Rebex: this will allow me to download a file from a server sFTP. Here are my Codedom settings:

Public Shared Function compile_Stub(ByVal input As String, ByVal output As String, ByVal resources As String, ByVal showError As Boolean, Optional ByVal icon_Path As String = Nothing) As Boolean

    Dim provider_Args As New Dictionary(Of String, String)()
    provider_Args.Add("CompilerVersion", "v3.5")

    Dim provider As New Microsoft.VisualBasic.VBCodeProvider(provider_Args)
    Dim c_Param As New Compiler.CompilerParameters
    Dim c_Args As String = " /target:winexe /platform:x86 /optimize "

    If Not icon_Path = Nothing Then
        c_Args = c_Args & "/win32icon:" & icon_Path
    End If

    c_Param.GenerateExecutable = True
    c_Param.OutputAssembly = output
    c_Param.EmbeddedResources.Add(resources)
    c_Param.CompilerOptions = c_Args
    c_Param.IncludeDebugInformation = False
    c_Param.ReferencedAssemblies.AddRange({"C:\Users\marsh\Desktop\project\Galaxy\packages\Rebex.Common.5.0.7119\lib\net35\Rebex.Common.dll", "C:\Users\marsh\Desktop\project\Galaxy\packages\Rebex.Networking.5.0.7119\lib\net35\Rebex.Networking.dll", "C:\Users\marsh\Desktop\project\Galaxy\packages\Rebex.Sftp.5.0.7119\lib\net35\Rebex.Sftp.dll", "mscorlib.dll", "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Management.dll", "System.Dll", "System.Drawing.Dll", "System.Windows.Forms.Dll", "System.Data.Dll", "System.Xml.Dll"})
    c_Param.GenerateInMemory = True
    Dim c_Result As Compiler.CompilerResults = provider.CompileAssemblyFromSource(c_Param, input)
    If c_Result.Errors.Count = 0 Then
        Return True
    Else
        If showError Then
            For Each _Error As Compiler.CompilerError In c_Result.Errors
                MessageBox.Show("ERREUR de compilation" & vbNewLine &
          "FileName: " & _Error.FileName & vbNewLine &
          "Ligne: " & _Error.Line & vbNewLine & "ErrorText: " &
          _Error.ErrorText & vbNewLine &
          "Column: " &
          _Error.Column & vbNewLine &
          "Type d'erreur (True = avertissement, False = Erreur ): " &
          _Error.IsWarning & vbNewLine & "ErrorNumber: " &
          _Error.ErrorNumber)
            Next
            Return False
        End If
        Return False
    End If

End Function

Despite having correctly implemented the libraries in question in my Codedom settings, nothing happens when I try to use them: no error, my application stops at the execution. The Rebex libraries are provided by the NuGet installation: Rebex.Common.dll, Rebex.Networking.dll, Rebex.Sftp.dll. The parameters that I have written in my code to import these libraries are however in agreement with this documentation.

My executable freeze when I implement this part of the code in my Stub Source.vb:

        Dim sftp As New Rebex.Net.Sftp()
        sftp.Connect(hostname)

        ' log in
        sftp.Login(username, password)

I really do not understand where this problem comes from. The fact that no error appears blocks me more: I do not know which way to go to solve the error. Could you help me?

0

There are 0 answers