3.5 Source Code for release 2013.1.8?

Jan 13, 2013 at 10:36 AM

Hello, are you able to provide the source code for .net 3.5 for the stable release?

 

Thank you,

 

Gerri

Coordinator
Jan 13, 2013 at 9:56 PM

Hi,

 

Unfortunately not but if you want to you can produce it your self.

You can download the project using source code tab, this is where I have a project that produces 3.% assembly.

The way it works is that it uses files from .NET 4.0 source code and for things that do no work in .NET 3.5 it replaces file.

so you will see version specific files with .NET35 or .NET40 ending.

 

Hope it helps,

Thanks,

Oleg

Jan 13, 2013 at 11:49 PM

Thanks Oleg, I downloaded the source successfully. I had to make a few changes to make it compile in VS2008 (replacing default parameters with overloaded functions).

I am having a problem with the downloaded source version vs. the binary file. I am able to use the binary 3.5 dll successfully to sftp a filestream. When I use the downloaded source version, I always get an error when trying to connect to the FTP host. 

The error I get is 

Message        "Session operation has timed out"   string

StackTrace    "   at Renci.SshNet.Session.WaitHandle(WaitHandle waitHandle) in C:\\Projects\\sshnet-22445\\Renci.SshClient\\Renci.SshNet\\Session.cs:line 643\r\n   at Renci.SshNet.Session.Connect() in C:\\Projects\\sshnet-22445\\Renci.SshClient\\Renci.SshNet\\Session.cs:line 538\r\n   at Renci.SshNet.BaseClient.Connect() in C:\\Projects\\sshnet-22445\\Renci.SshClient\\Renci.SshNet\\BaseClient.cs:line 117\r\n   at ReportGenerationLibrary.BusinessObject.FtpFileBO.getSFTPClient() in C:\\Projects\\ReportGenerationLibrary\\BusinessObject\\FtpFileBO.cs:line 288"   string

Does this error mean anything to you?


Regards,


Gerri

Jan 14, 2013 at 3:55 PM

I tried the exact same thing with the exact same results.

When I compile the 35 project in VS2010, however, the compiled DLL works just fine.  It seems like something is not compatible between VS2008 and VS2010.  A DLL compiled in VS2010 may still be referenced by a VS2008 project as long as the framework 3.5 is selected.  Interesting- (and glad I am not the only one who saw this)

-Mike

Coordinator
Jan 14, 2013 at 5:57 PM

Hi Gerri,

 

Does it connect to SSH server if you try to execute a command or to do anything else?

I suspect I have an error somewhere .NET35 specific classes, I would look there and see if I can figure out what it was waiting for that it times out.

 

Hope it helps.

Thanks,

Oleg

Jan 14, 2013 at 9:18 PM

HI MIke, thanks for your reply, it's good to know I'm not alone :-) I will try compiling in VS2010 (passing it to someone who has that version) and see if that resolves the issue. 

Hi Oleg, I am getting this error when trying to connect to the SFTP Client - (using the version compiled from the source code download). The exact same code works fine if I use the downloaded dll binary file. 

Regards,

Gerri

Jan 14, 2013 at 9:54 PM

Gerri/Oleg,

Here is exaclty where mine times out:

Line 538 of Session.cs calls this during .Connect():

 // Wait for key exchange to be completed 

 this.WaitHandle(this._keyExchangeCompletedWaitHandle);

Inside WaitHandle (line 629), I hit the TimeOut Case in the following:

        internal void WaitHandle(WaitHandle waitHandle)
        {
            var waitHandles = new WaitHandle[]
                {
                    this._exceptionWaitHandle,
                    waitHandle,
                };

            switch (EventWaitHandle.WaitAny(waitHandles, this.ConnectionInfo.Timeout))
            {
                case 0:
                    throw this._exception;
//--->Here
                case System.Threading.WaitHandle.WaitTimeout:
                    this.SendDisconnect(DisconnectReason.ByApplication, "Operation timeout");
                    throw new SshOperationTimeoutException("Session operation has timed out");
                default:
                    break;
            }
        }

It is like the KeyExchange message never comes through, or the listener is not wired up correctly.

Like I said above though, build it in VS2010 and it works fine.

Thanks, Mike

Coordinator
Jan 15, 2013 at 2:48 PM

 

Hi,

 

I guess differences could be what default option or compile being used by 2008 vs 2010.

As FYI, I used 2012 to build all my code.

 

Thanks,

Oleg

Feb 5, 2013 at 2:05 PM
Hi,

I recently started using this library. I get the same error as above. Any suggestions on how to resolve it? I did find the vs2010 compilation to be fine for .NET 3.5. This problem for some reason occurs with vs2008. Any insights would be helpful

Thanks

Elson
Feb 5, 2013 at 9:31 PM
Hi there.

I would also like to use this for an existing .NET 3.5 project under VS2008. I have duplicated the timeout problem and verified that it does indeed work if compiled with VS2010. Then I did some debugging in VS2008.

KeyExchangeDiffieHellmanGroupExchangeSha256.cs at line 36 in the Start method, I found that the statement
 this.Session.MessageReceived += Session_MessageReceived;
seems to simply hang. Same line executes just fine in VS2010. Don't see anything wrong syntactically and Googling for weird EventHandler<T>hangs has not yielded much. Has anybody seen a problem with this construct/syntax?

Matt
Feb 6, 2013 at 6:24 AM
Hi all,

Our workaround was to compile the source code in VS2010, and use that dll file in our VS2008 project. This was adequate for us, as we don't plan to change or update the code very often.

Regards,

Gerri
Feb 7, 2013 at 3:21 PM
Good Morning.

Simply using a VS2010 compiled version is probably the right solution, as it seems several folks are doing it, but it bugged me not knowing WHY seemingly correct code worked differently between compilers.

'this.Session.MessageReceived' is declared
 internal event EventHandler<MessageEventArgs<Message>> MessageReceived;
The Visual Studio 2008 and 2010 C# compilers treat the 'event' access modifier differently. See "Visual C# 2010 Breaking Changes" at http://msdn.microsoft.com/en-us/library/ee855831(v=vs.100).aspx; it talks about changes in Event synchronization.

Looking at the CIL for the VS2008 compiled version, I see the 'synchronized' attribute on the Renci.SshNet.Session::add_MessageReceived Method. That attribute is NOT present in the VS2010 version. From the CLI standard (ECMA-335) "Synchronized methods. A lock that is visible across threads controls entry to the body of a synchronized method. For instance and virtual methods the lock is associated with the this pointer."

So basically, the 'synchronized' attribute in the VS2008 version is equivalent to 'lock(this)' on the Session object. Well, Session.Connect wraps the whole connection attempt and key exchange in a 'lock(this)', so the delegate add blocks until the key exchange attempt times out and Session.Connect exits.

The rest of the code seems to handle event synchronization in accordance with the VS2010 recommendations, so it would indeed seem safer to go with VS2010, rather than re-work it for VS2008.

Matt
Feb 7, 2013 at 5:56 PM
Hey Matt, Very nice work- a gold star for you! :) I hate it when circumstances like this do not have an explaination, so hats off to you sir.

Thanks, Mike
Coordinator
Feb 7, 2013 at 6:58 PM
Hey Matt,

Thanks for finding this out.
I originally started this project in VS.NET 2010 and .NET 4.0 so wouldn't know where to look.

Thanks,
Oleg
Feb 8, 2013 at 4:49 AM
Hey Matt,

Thanks a lot for pointing this out.

Regards,

Elson
Apr 5, 2013 at 3:01 PM
Hey everyone,

I imported and compiled the Renci 3.5 project into VS , built it and added the reference to my project, but lots of classes are not available. For example SshClient and SftpClient do not exist in the 3.5 project. Also the Common directory is practically empty. Is there anything additional I need to do in order to compile the 3.5 version ? Thanks in advance!
Coordinator
Apr 5, 2013 at 3:09 PM
Hi,

Yes,
.NET 3.5 source code is generated of .NET40 with some differentce for 3.5 located in .NET 3.5 project.

Basically you will need to merge .NET40 and .NET35 versions.

Hope it helps.

Thanks,
Oleg
Apr 26, 2013 at 3:01 PM
Edited Apr 29, 2013 at 2:05 PM
Hey everyone,

I've been trying unsuccessfully to build the source for .NET 3.5. I see some files have 2 versions - .cs or .NET40.cs. I've changed the project to target .NET 3.5 but should I also be replacing .NET40.cs files with the regular .cs file? The 4.0 files are very small and look incomplete. I don't see any files specific to .NET 3.5 Thanks in advance and my apologies for not understanding how this works.

Edit: Nevermind, didn't realize there was a separate project for 3.5. I'm all set now.
May 3, 2013 at 5:23 PM
where is the separate project? I am also looking for it.
May 3, 2013 at 5:28 PM
I figured this out. If you open the solution (Renci.SshNet.sln) you'll see a project named Renci.SshNet.NET35. Build that and it will produce a DLL (Renci.SshNet.NET35\bin\Debug\Renci.SshNet.dll) that works in .NET 3.5. Hope this helps
Marked as answer by drieseng on 5/7/2014 at 1:13 PM
May 8, 2014 at 6:41 PM
sharky2k10 wrote:
I figured this out. If you open the solution (Renci.SshNet.sln) you'll see a project named Renci.SshNet.NET35. Build that and it will produce a DLL (Renci.SshNet.NET35\bin\Debug\Renci.SshNet.dll) that works in .NET 3.5. Hope this helps
Did you do this in Visual Studio 2008 or a newer version?
May 12, 2014 at 1:36 PM
nbaker76 wrote:
sharky2k10 wrote:
I figured this out. If you open the solution (Renci.SshNet.sln) you'll see a project named Renci.SshNet.NET35. Build that and it will produce a DLL (Renci.SshNet.NET35\bin\Debug\Renci.SshNet.dll) that works in .NET 3.5. Hope this helps
Did you do this in Visual Studio 2008 or a newer version?
I did this in Visual Studio 2010 Professional.