VB2005 Express - WeOnlyDo Discussion board

VB2005 Express (wodSFTP / wodSFTP.NET / wodSFTPdll)

by Robert, Saturday, August 04, 2007, 11:48 (6133 days ago)

Hi,

I am trying to get the OCX working in a simple VB2005 Express example. But somehow I get errors stating the following:

System.Reflection.TargetInvocationException was unhandled
Message= Exception has been thrown by the target of an invocation.
Source= mscorlib
StackTrace:
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at AxWODSSHLib.AxwodSSH.Connect()
at WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e) in C:Documents and SettingsRobertLocal SettingsApplication DataTemporary ProjectsWindowsApplication1Form1.vb:line 6
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

I am not sure how to use this: the examples provided are not for VB2005 Express. Can you help me with this?

Robert

Re: VB2005 Express

by wodDamir, Saturday, August 04, 2007, 13:00 (6133 days ago) @ Robert

Hi Robert,

I've just tried importing and using wodSSH.ocx in VB2005 Express, and everything worked for me. Does this occur with .dll too?

Also, if you could contact me on techsupport@weonlydo.com i could send you a simple basic sample that worked on my side.

Regards,
Damba

Re: VB2005 Express

by Robert, Saturday, August 04, 2007, 13:41 (6133 days ago) @ wodDamir

Hi,

Could you please send me the example? Thanks!

Robert

Re: VB2005 Express

by wodDamir, Saturday, August 04, 2007, 15:53 (6133 days ago) @ Robert

Hi Robert,

Can you contact me thru techsupport@weonlydo.com ?

I cannot attach a sample here. Also, did you try the .dll?

Regards,
Damba

Re: VB2005 Express

by Robert, Saturday, August 04, 2007, 17:27 (6133 days ago) @ wodDamir

Hi Robert,

Can you contact me thru techsupport@weonlydo.com ?

I cannot attach a sample here. Also, did you try the .dll?

Regards,
Damba

Hi Damba,

I have not tested the .dll yet. I am a newbe and evaluating your SSH solution. I was not able to convert the VB examples because I do not have a VB 5 or 6 environment.

I have send you an email with a request to sent the example.

Thanks,

Robert

Re: VB2005 Express

by wodDamir, Saturday, August 04, 2007, 18:14 (6133 days ago) @ Robert

Robert,

I've checked, but we haven't received an e-mail from you.

Basically, the way to use the component in VB2005 Express would be to do the following:

1. Choose Project->Add reference from the menu
2. Select Browse tab, browse to System32 folder and import wodSSH.ocx
3. Initialize the component (this should work):

Basically, the following code should work:
---------------------------------------------------------------------
Dim WithEvents ssh1 As WODSSHLib.wodSSH
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ssh1 = New WODSSHLib.wodSSH
ssh1.Hostname = your_host
ssh1.Login = your_login
ssh1.Password = your_pass
ssh1.Connect()
End Sub

Private Sub ssh1_Received(ByVal ByteCount As Short) Handles ssh1.Received
TextBox1.Text += ssh1.Receive()
End Sub
---------------------------------------------------------------------
Also, this sample only connects to the server, and prints out the received text.

Hope this helped.

Regards,
Damba

Re: VB2005 Express

by Robert, Monday, August 06, 2007, 11:45 (6131 days ago) @ wodDamir

Robert,

I've checked, but we haven't received an e-mail from you.

Basically, the way to use the component in VB2005 Express would be to do the following:

1. Choose Project->Add reference from the menu
2. Select Browse tab, browse to System32 folder and import wodSSH.ocx
3. Initialize the component (this should work):

Basically, the following code should work:
---------------------------------------------------------------------
Dim WithEvents ssh1 As WODSSHLib.wodSSH
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ssh1 = New WODSSHLib.wodSSH
ssh1.Hostname = your_host
ssh1.Login = your_login
ssh1.Password = your_pass
ssh1.Connect()
End Sub

Private Sub ssh1_Received(ByVal ByteCount As Short) Handles ssh1.Received
TextBox1.Text += ssh1.Receive()
End Sub
---------------------------------------------------------------------
Also, this sample only connects to the server, and prints out the received text.

Hope this helped.

Regards,
Damba

Hi Damba,

This was a very good start. But I have a small issue. I changed your code to:
[code]Public Class Form1
Dim WithEvents ssh1 As WODSSHLib.wodSSH
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ssh1 = New WODSSHLib.wodSSH
ssh1.Hostname = 192.168.0.240
ssh1.Login = ssh
ssh1.Password = test
ssh1.Protocol = WODSSHLib.ProtocolsEnum.SSH2
ssh1.Prompt = [ssh@Robert HS] >
ssh1.Blocking = True
ssh1.TerminalType = vt100
ssh1.Connect()
End Sub

Private Sub ssh1_Received(ByVal ByteCount As Short) Handles ssh1.Received
Dim ReceiveText As String
TextBox1.Clear()
TextBox2.Clear()
ReceiveText = ssh1.Receive()
TextBox2.Text += status: & CStr(ssh1.State) & vbCrLf
TextBox2.Text += stringlength: & CStr(ReceiveText.Length) & vbCrLf
TextBox1.Text += ReceiveText
End Sub

Private Sub ssh1_Connected(ByVal ErrorCode As Short, ByVal ErrorText As String) Handles ssh1.Connected
TextBox2.Text += connected & vbCrLf
End Sub

Private Sub ssh1_Prompt_Received() Handles ssh1.PromptReceived
TextBox2.Text += prompt received & vbCrLf
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ErrText As String
ErrText = ssh1.Execute( ip hotspot user print & vbCr)
TextBox2.Text += ErrText & vbCrLf
End Sub
End Class
[/code]

The thing is: if I send the print command via the ssh1.Execute the return value I get is not the complete list. I am not sure what I am doing wrong? Do you have any insights?

Thanks,

Robert

Re: VB2005 Express

by wodDamir, Monday, August 06, 2007, 12:06 (6131 days ago) @ Robert

Robert,

What do you receive? And what do you expect to have received?

Maybe Send Method would help? Can you try it?

Regards,
Damba

Re: VB2005 Express

by Robert, Monday, August 06, 2007, 12:47 (6131 days ago) @ wodDamir

Robert,

What do you receive? And what do you expect to have received?

Maybe Send Method would help? Can you try it?

Regards,
Damba

Hi Damba,

Thanks for the help. This gives the list i needed!
Do you have any idea why the execute method only returns a peace of the list? Is the output restricted to a certain number of bytes?

But for now: send works fine!

Thanks,

Robert

Re: VB2005 Express

by wodDamir, Monday, August 06, 2007, 13:13 (6131 days ago) @ Robert

Robert,

I can't tell you for certain... But if Send gives you the desired output, use it freely. Maybe Execute would work if you provided a Prompt argument so that the component knows when execute is completed.

Did you check ErrText variable? Did it contain the correct output?

Regards,
Damba