EldoS | Feel safer!

Software components for data protection, secure storage and transfer

sFTP in CF2.0

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
#7244
Posted: 08/06/2008 12:21:29
by kcee b (Basic support level)
Joined: 08/06/2008
Posts: 8

Hello guys

I have been struggling with setting up the connection to the server under Compact Framework environment. I am writing my code with reference to the "SimpleSftpDemo" that was installed at the time of installation. Let me put the code first:

Code
Imports System.Net
Imports System.Net.Sockets
Imports System.Collections
Imports SBUtils
Imports SBSftpCommon
Imports SBSimpleSftp
Imports SBSSHKeyStorage

Public Class Form1
    Private KeyStorage As TElSSHMemoryKeyStorage
    Friend WithEvents SftpClient As SBSimpleSftp.TElSimpleSFTPClient

    Sub temp()
        SBUtils.Unit.SetLicenseKey("0645...589D")
        KeyStorage = New TElSSHMemoryKeyStorage
        SftpClient.KeyStorage = KeyStorage
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            temp()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        Try
            'Dim myElSimpleSFTPClient As SBSimpleSftp.TElSimpleSFTPClient = Nothing
            SftpClient.Port = 22
            SftpClient.Address = "www.TEST.com"
            SftpClient.Username = "SomeUserName"
            SftpClient.Password = "SomePassword"

            Try
                SftpClient.Open()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

            MsgBox("Connection seems to be made!! semi-Congratulations!!", MsgBoxStyle.ApplicationModal)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class


I am using the following dll libraries:
c:\program files\SecureBlackbox.NET\Assemblies\NET_CF20\SecureBlackbox.dll
c:\program files\SecureBlackbox.NET\Assemblies\NET_CF20\SecureBlackbox.SFTP.dll
c:\program files\SecureBlackbox.NET\Assemblies\NET_CF20\SecureBlackbox.SFTPCommon.dll
c:\program files\SecureBlackbox.NET\Assemblies\NET_CF20\SecureBlackbox.SSHClient.dll
c:\program files\SecureBlackbox.NET\Assemblies\NET_CF20\SecureBlackbox.SSHCommon.dll
c:\program files\SecureBlackbox.NET\Assemblies\NET_CF20\SecureBlackbox.SSHServer.dll

*Notice that I am using NET_CF20 whereas the Demo is using NET_20.

When I run the above code on the development platform(Windows CE 5.0), I am getting the following error:
NullReferenceException

In trying to search for an answer, I have visited numerous posts here in the forum as well as the KnowledgeBase.

My questions is how do I solve this problem and what am I missing that I can add onto my code to make it work.

------------------------------------------------------------------------

My next little question is:
How do I turn off compression via CompressionAlgorithms. For example, is this accomplished by writing the following code (I am referring to the Demo)?

Me.SftpClient.ForceCompression = False



Thanks in advance
Cheers
- Kevin
#7245
Posted: 08/06/2008 12:38:04
by Eugene Mayevski (EldoS Corp.)

Quote
kcee b wrote:
how do I solve this problem and what am I missing that I can add onto my code to make it work.


Please show the call stack of the exception.

Quote
kcee b wrote:
How do I turn off compression via CompressionAlgorithms. For example, is this accomplished by writing the following code (I am referring to the Demo)?


SftpClient.CompressionAlgorithms[SBSSHConstants.Unit.SSH_CA_ZLIB] = false
SftpClient.CompressionAlgorithms[SBSSHConstants.Unit.SSH_CA_ZLIB_DELAYED] = false


Sincerely yours
Eugene Mayevski
#7246
Posted: 08/06/2008 13:42:21
by kcee b (Basic support level)
Joined: 08/06/2008
Posts: 8

Give me 1/2 hour to make an update to my code and I will repost the Code with a call to stack of exception.

Thanks, Eugene
You(& your crew) rock.
#7247
Posted: 08/06/2008 14:05:20
by Eugene Mayevski (EldoS Corp.)

Be sure that you are running the latest build - there was a similar problem about a year or two ago, but it was solved then. I don't even remember a solution now.


Sincerely yours
Eugene Mayevski
#7248
Posted: 08/06/2008 14:16:49
by kcee b (Basic support level)
Joined: 08/06/2008
Posts: 8

Just having a little issue with a call to stack of exception. The member(StackTrace) seems to be giving some issue here with Compact Framework 2.0. I will post it here once it is resolved ASAP.

Thanks Eugene
#7249
Posted: 08/06/2008 14:39:04
by Eugene Mayevski (EldoS Corp.)

When the application is run under IDE and exception happens, execution usually stops at the place, where the exception happened. Then you can chck the call stack in the debug window.


Sincerely yours
Eugene Mayevski
#7250
Posted: 08/06/2008 15:15:45
by kcee b (Basic support level)
Joined: 08/06/2008
Posts: 8

Ok....it was just a simple call to see the StackTrace.

I have modified the code to:
Code
Imports System.Net
Imports System.Net.Sockets
Imports System.Collections
Imports SBUtils
Imports SBSftpCommon
Imports SBSimpleSftp
Imports SBSSHKeyStorage


Public Class Form1
    Private KeyStorage As TElSSHMemoryKeyStorage
    Friend WithEvents SftpClient As SBSimpleSftp.TElSimpleSFTPClient


    Sub temp()
        SBUtils.Unit.SetLicenseKey("0645...589D")
        KeyStorage = New TElSSHMemoryKeyStorage
        SftpClient.KeyStorage = KeyStorage
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            temp()
        Catch ex As Exception
            MsgBox("Message: " + ex.Message)
            MsgBox("StackTrace: " + ex.StackTrace)
        End Try

        'Try
        '    'Dim myElSimpleSFTPClient As SBSimpleSftp.TElSimpleSFTPClient = Nothing
        '    SftpClient.Port = 22
        '    SftpClient.Address = "www.TEST.com"
        '    SftpClient.Username = "SomeUserName"
        '    SftpClient.Password = "SomePassWord"

        '    Try
        '        SftpClient.Open()
        '    Catch ex As Exception
        '        MsgBox(ex.Message)
        '    End Try

        '    MsgBox("Connection seems to be made!! semi-Congratulations!!", MsgBoxStyle.ApplicationModal)
        'Catch ex As Exception
        '    MsgBox(ex.Message)
        'End Try
    End Sub
End Class


I have not implement the following on the code because it gives me wiggley underscore in VS2005 - error.(I wonder why?)
Quote

SftpClient.CompressionAlgorithms[SBSSHConstants.Unit.SSH_CA_ZLIB] = false
SftpClient.CompressionAlgorithms[SBSSHConstants.Unit.SSH_CA_ZLIB_DELAYED] = false


[code]
The stack of exception shows up as following:

StackTrace: at ELDOS.test2.Form1.temp()
at ELDOS.test2.Form1.Button1_Click()
at System.Windows.Forms.Control.OnClick()
at System.Windows.Forms.Button.OnClick()
at System.Windows.Forms.ButtonBase.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at ELDOS.test2.Form1.Main()


All I am doing is just putting the validation key and I wonder if the missing code that you have recommended is what's causing the problem-but VB .net says the two-lines of code from you is an error.

I am using the latest version of BlackBox for sFTP, downloaded yesterday.

Thanks
Kev
#7251
Posted: 08/06/2008 16:00:46
by kcee b (Basic support level)
Joined: 08/06/2008
Posts: 8

Hey Eugene

I haven't found the code that you have mentioned in the sFTP client Demo. Is there any special attention required to put the code in my code?

Code
SftpClient.CompressionAlgorithms[SBSSHConstants.Unit.SSH_CA_ZLIB] = false
SftpClient.CompressionAlgorithms[SBSSHConstants.Unit.SSH_CA_ZLIB_DELAYED] = false


Thanks
#7252
Posted: 08/06/2008 18:03:58
by Dmytro Bogatskyy (EldoS Corp.)

Quote

I have not implement the following on the code because it gives me wiggley underscore in VS2005 - error.(I wonder why?)
SftpClient.CompressionAlgorithms[SBSSHConstants.Unit.SSH_CA_ZLIB] = false
SftpClient.CompressionAlgorithms[SBSSHConstants.Unit.SSH_CA_ZLIB_DELAYED] = false

Please, change a square brackets "[]" to round brackets "()"

Quote
Ok....it was just a simple call to see the StackTrace.

Please, check in Output Window if the correct assemblies are deployed (not from GAC).
P.S. In your code I don't see where SftpClient object is created.
#7253
Posted: 08/07/2008 00:13:41
by kcee b (Basic support level)
Joined: 08/06/2008
Posts: 8

Quote
Please, check in Output Window if the correct assemblies are deployed (not from GAC).
P.S. In your code I don't see where SftpClient object is created.


It is declared in the upper portion of the class implementation

Public Class Form1
Private KeyStorage As TElSSHMemoryKeyStorage
Friend WithEvents SftpClient As SBSimpleSftp.TElSimpleSFTPClient



Quote
Please, change a square brackets "[]" to round brackets "()"

I have tried this and it got rid of the wiggley underscore. Thanks.

Quote
Please, check in Output Window if the correct assemblies are deployed (not from GAC).

What is GAC? I am assuming that the way you check this is by observing the directories?

Here is the content of the Output Window:

------ Build started: Project: ELDOS.test2, Configuration: Debug Any CPU ------
ELDOS.test2 -> C:\Documents and Settings\kevinb\My Documents\Visual Studio 2005\Projects\ELDOS.test2\ELDOS.test2\bin\Debug\ELDOS.test2.exe
------ Deploy started: Project: ELDOS.test2, Configuration: Debug Any CPU ------
Deploying 'C:\Program Files\EldoS\SecureBlackbox.NET\Assemblies\NET_CF20\SecureBlackbox.SSHServer.dll'
Deploying 'C:\Program Files\EldoS\SecureBlackbox.NET\Assemblies\NET_CF20\SecureBlackbox.SSHCommon.dll'
Deploying 'C:\Program Files\EldoS\SecureBlackbox.NET\Assemblies\NET_CF20\SecureBlackbox.SSHClient.dll'
Deploying 'C:\Program Files\EldoS\SecureBlackbox.NET\Assemblies\NET_CF20\SecureBlackbox.SFTPCommon.dll'
Deploying 'C:\Program Files\EldoS\SecureBlackbox.NET\Assemblies\NET_CF20\SecureBlackbox.SFTP.dll'
Deploying 'C:\Program Files\EldoS\SecureBlackbox.NET\Assemblies\NET_CF20\SecureBlackbox.dll'
Deploying 'C:\Documents and Settings\kevinb\My Documents\Visual Studio 2005\Projects\ELDOS.test2\ELDOS.test2\bin\Debug\ELDOS.test2.exe'
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========


And I am still getting "NullReferenceException" on the same spot.

Unless I am wrong, I don't think it is getting deployed from GAC. Man, it costed me almost a day to just to set up validation process and I don't know whether I want to spend any more time on this. :( I wonder how long it would take to get the actual coding working through ELDOS.

Too tired. I will check on the post tomorrow morning.

Have good night ELDOS.
- kev
Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.

Reply

Statistics

Topic viewed 5954 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!