Vb.net 使用外部库时应用程序冻结
我的应用程序包含一个主文件,允许使用Codedom生成可执行文件。此可执行文件由我的文件Vb.net 使用外部库时应用程序冻结,vb.net,compiler-errors,stub,codedom,system-codedom-compiler,Vb.net,Compiler Errors,Stub,Codedom,System Codedom Compiler,我的应用程序包含一个主文件,允许使用Codedom生成可执行文件。此可执行文件由我的文件Source.vb生成 我想在后者中使用外部库。特别是,这是Rebex:这将允许我从服务器sFTP下载一个文件。 以下是我的Codedom设置: Public Shared Function compile_Stub(ByVal input As String, ByVal output As String, ByVal resources As String, ByVal showError As Bool
Source.vb
生成
我想在后者中使用外部库。特别是,这是Rebex:这将允许我从服务器sFTP下载一个文件。
以下是我的Codedom设置:
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
尽管在我的Codedom设置中正确地实现了有问题的库,但当我尝试使用它们时,什么也没有发生:没有错误,我的应用程序在执行时停止。Rebex库由NuGet安装提供:Rebex.Common.dll
,Rebex.Networking.dll
,Rebex.Sftp.dll
。但是,我在代码中编写的用于导入这些库的参数与此一致
当我在存根Source.vb中实现这部分代码时,我的可执行文件冻结:
Dim sftp As New Rebex.Net.Sftp()
sftp.Connect(hostname)
' log in
sftp.Login(username, password)
我真的不明白这个问题从何而来。没有出现错误这一事实更加阻碍了我:我不知道该如何解决错误。你能帮我吗