Network Directory Not accessible through .NET Assembly

Advertisement

jamesshca
Joined:
Posts:
6

Network Directory Not accessible through .NET Assembly

Hi,
I am using this new .NET dll and was having problems when I use this in my application from a network drive location which is a shared location. All the time the WinSCP.dll seems to truncate the root element. Say for example, if I am using the following path '\\NetworkRoot\dev\myproject\' where my project code resides, the WinSCP dll throws an exception that it can't find the WinSCP.dll in the following path '/dev/myproject'. Notice that this message somehow truncates the root folder name. I suppose this may be because your code doesn't properly amke use of the System.Reflection classes to get the path to the executing assembly when the project is run from some network location. Have you released the source code for this dll, so that I can take a look?

Please resolve this issue. I appreciate your help.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Network Directory Not accessible through .NET Assembly

Thanks for your post.
Assembly source code is not released yet.
The code for determining assembly path is:
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(new Uri(codeBase));
string codeBasePath Uri.UnescapeDataString(uri.Path);
string path = Path.GetDirectoryName(codeBasePath);
What do you suggest?

Reply with quote

jamesshca
Joined:
Posts:
6

Code Fix - .NET dll

Hi Martin,

Given below is a tested code fix which I believe returns me the complete path of the network directory where the dll is located. See my comments below: Let me know if this works.
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
//UriBuilder uri = new UriBuilder(new Uri(codeBase)); //instead of using this line
Uri local = new Uri(codeBase); //use this
//string codeBasePath = Uri.UnescapeDataString(uri.Path);
string codeBasePath = Uri.UnescapeDataString(local.LocalPath); //this local.LocalPath returns me complete Uri instead of truncated host
string path = Path.GetDirectoryName(codeBasePath); //this gives me full path
Thanks,
James

Reply with quote

jamesshca
Joined:
Posts:
6

Re: Network Directory Not accessible through .NET Assembly

martin wrote:

This bug has been added to the tracker:
https://winscp.net/tracker/841

I have sent you an email with a development version of WinSCP to address you have used to register on this forum.

I tested it out. Now the program hangs once it executes session.Open(sessionOptions). It doesn't respond at all. I can't tell what exactly the problem here is when it tries to access the WinSCP dll in my project folder which is located in the network drive. Now it doesn't truncate the root of the network folder but it just hangs.

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: Network Directory Not accessible through .NET Assembly

Please set Session.DebugLogPath and post or email the log file.

Reply with quote

jamesshca
Joined:
Posts:
6

Log File

[2012-04-23 09:44:44Z] [000a] Executing Assembly: WinSCP, Version=1.0.0.447, Culture=neutral, PublicKeyToken=b5f19f5762436b89; Path: \\MyDrive\dev\\Testing_WinScp_dll\Testing_WinScp_dll\bin\Debug\WinSCP.DLL; Location: \\MyDrive\dev\\Testing_WinScp_dll\Testing_WinScp_dll\bin\Debug\WinSCP.dll; Product: 5.0.6.0
[2012-04-23 09:44:44Z] [000a] Entry Assembly: Testing_WinScp_dll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
[2012-04-23 09:44:44Z] [000a] Operating system: Microsoft Windows NT 4.1.2500 Service Pack 2
[2012-04-23 09:44:44Z] [000a] User: jj@Home; Interactive: True
[2012-04-23 09:44:44Z] [000a] Runtime: 2.0.50727.3615
[2012-04-23 09:44:44Z] [000a] Console encoding: Input: OEM United States (034); Output: OEM United States (034)
[2012-04-23 09:44:53Z] [000a] CallstackAndLock..ctor entering
[2012-04-23 09:44:53Z] [000a] ExeSessionProcess..ctor entering
[2012-04-23 09:44:53Z] [000a] ExeSessionProcess.GetExecutablePath entering
[2012-04-23 09:44:53Z] [000a] ExeSessionProcess.GetExecutablePath leaving
[2012-04-23 09:44:53Z] [000a] EXE executable path resolved to \\MyDrive\dev\\Testing_WinScp_dll\Testing_WinScp_dll\bin\Debug\winscp.exe
[2012-04-23 09:44:53Z] [000a] ExeSessionProcess..ctor leaving
[2012-04-23 09:44:53Z] [000a] ExeSessionProcess.Start entering
[2012-04-23 09:44:53Z] [000a] ExeSessionProcess.InitializeConsole entering
[2012-04-23 09:44:53Z] [000a] ExeSessionProcess.InitializeConsole leaving
[2012-04-23 09:44:53Z] [000a] ExeSessionProcess.InitializeChild entering
[2012-04-23 09:44:53Z] [000a] Starting "\\MyDrive\dev\\Testing_WinScp_dll\Testing_WinScp_dll\bin\Debug\winscp.exe" /xmllog="C:\Documents and Settings\jj\Local Settings\Temp\tmp622.tmp" /xmlgroups /nointeractiveinput /dotnet=506 /console /consoleinstance=_7176_418
[2012-04-23 09:44:54Z] [000a] ExeSessionProcess.InitializeChild leaving
[2012-04-23 09:44:54Z] [000a] ExeSessionProcess.Start leaving
[2012-04-23 09:44:54Z] [000a] Command: [option batch on]
[2012-04-23 09:44:54Z] [000a] ExeSessionProcess.ExecuteCommand entering
[2012-04-23 09:44:54Z] [000a] ExeSessionProcess.ExecuteCommand leaving
[2012-04-23 09:44:54Z] [000a] Command: [option confirm off]
[2012-04-23 09:44:54Z] [000a] ExeSessionProcess.ExecuteCommand entering
[2012-04-23 09:44:54Z] [000a] ExeSessionProcess.ExecuteCommand leaving
[2012-04-23 09:44:54Z] [000a] Session.SessionOptionsToOpenArguments entering
[2012-04-23 09:44:54Z] [000a] Session.SessionOptionsToOpenSwitches entering
[2012-04-23 09:44:54Z] [000a] Session.SessionOptionsToOpenSwitches leaving
[2012-04-23 09:44:54Z] [000a] Session.SessionOptionsToOpenArguments leaving
[2012-04-23 09:44:54Z] [000a] Command: [open -hostkey="ssh-dss 1024 00:30:qa:95:c9:06:a0:00:00:d0:f9:de:c5:3b:8d:pa" -timeout=15 "sftp://jj:jj@jj@ssh.home.com"]
[2012-04-23 09:44:54Z] [000a] ExeSessionProcess.ExecuteCommand entering
[2012-04-23 09:44:54Z] [000a] ExeSessionProcess.ExecuteCommand leaving
Last edited by jamesshca on 2012-04-23 18:24; edited 1 time in total

Reply with quote

martin
Site Admin
martin avatar

Re: Network Directory Not accessible through .NET Assembly

My guess is that winscp.exe you are starting from network folder is not 5.0.6 beta. Did you override the version check with Session.DisableVersionCheck? Note that the winscp.dll works with winscp.exe 5.0.6 beta only.

Reply with quote

Advertisement

jamesshca
Joined:
Posts:
6

Re: Network Directory Not accessible through .NET Assembly

martin wrote:

My guess is that winscp.exe you are starting from network folder is not 5.0.6 beta. Did you override the version check with Session.DisableVersionCheck? Note that the winscp.dll works with winscp.exe 5.0.6 beta only.


Yes, I tired both ways. First I tried using the exe that you sent alongwith the WinSCP dll which resulted in an exception because of version of WinSCP. So then I used Session.DisableVersionCheck and after the session.Open(sessionOptions) it simply hangs. I tried using the 5.0.6 beta alongwith the dll you sent but still the same result.

Please advise. Maybe if you could try using it at your end from a netwrok drive location for your project then you could be able to find the issue.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Network Directory Not accessible through .NET Assembly

jamesshca wrote:

Yes, I tired both ways. First I tried using the exe that you sent alongwith the WinSCP dll which resulted in an exception because of version of WinSCP. So then I used Session.DisableVersionCheck and after the session.Open(sessionOptions) it simply hangs. I tried using the 5.0.6 beta alongwith the dll you sent but still the same result.

Please advise. Maybe if you could try using it at your end from a netwrok drive location for your project then you could be able to find the issue.
I've sent you new build. Please repeat the test with it, without DisableVersionCheck. Post a debug log file.

I've tried it myself. But it works for me.

Reply with quote

sorvani
Joined:
Posts:
2
Location:
St Louis, Missouri

I am having this problem, any timeline for this to make it into the beta?

I can specify the executable path, but then it fails to find the DLL.
"/some/long/unc/path/name/in/this/format/WinSCP.dll"

The path I specified was
"\\some\long\unc\path\name\in\this\format\WinSCP.exe"

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

sorvani wrote:

I am having this problem, any timeline for this to make it into the beta?

I can specify the executable path, but then it fails to find the DLL.
"/some/long/unc/path/name/in/this/format/WinSCP.dll"

The path I specified was
"\\some\long\unc\path\name\in\this\format\WinSCP.exe"
Thanks for your report.
I have sent you an email with a development version of WinSCP to address you have used to register on this forum.

Reply with quote

Advertisement

sorvani
Joined:
Posts:
2
Location:
St Louis, Missouri

Failed due to version check. I disabled the version check and it sent.

[2012-05-02 14:20:18Z] [000a] Executing Assembly: WinSCP, Version=1.0.0.481, Culture=neutral, PublicKeyToken=b5f19f5762436b89; Path: \\piasa\ClientApps\Programs\SVN_Controlled_Code\Piasa_VS2008\trunk\ElectronicFileTransfer\ElectronicFileTransfer\bin\Debug\WinSCP.DLL; Location: \\Piasa\ClientApps\Programs\SVN_Controlled_Code\Piasa_VS2008\trunk\ElectronicFileTransfer\ElectronicFileTransfer\bin\Debug\WinSCP.dll; Product: 5.0.6.0
[2012-05-02 14:20:18Z] [000a] Entry Assembly: ElectronicFileTransfer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
[2012-05-02 14:20:18Z] [000a] Operating system: Microsoft Windows NT 5.1.2600 Service Pack 3
[2012-05-02 14:20:18Z] [000a] User: jared@PIASA@MXM7460CSC; Interactive: True
[2012-05-02 14:20:18Z] [000a] Runtime: 2.0.50727.3625
[2012-05-02 14:20:18Z] [000a] Console encoding: Input: Western European (Windows) (1252); Output: Western European (Windows) (1252)
[2012-05-02 14:20:23Z] [000a] CallstackAndLock..ctor entering
[2012-05-02 14:20:23Z] [000a] ExeSessionProcess..ctor entering
[2012-05-02 14:20:23Z] [000a] ExeSessionProcess.GetExecutablePath entering
[2012-05-02 14:20:23Z] [000a] ExeSessionProcess.GetExecutablePath leaving
[2012-05-02 14:20:23Z] [000a] EXE executable path resolved to \\piasa\ClientApps\Programs\SVN_Controlled_Code\Piasa_VS2008\trunk\ElectronicFileTransfer\ElectronicFileTransfer\bin\Debug\winscp.exe
[2012-05-02 14:20:23Z] [000a] ExeSessionProcess.CheckVersion entering
[2012-05-02 14:20:23Z] [000a] Version of \\piasa\ClientApps\Programs\SVN_Controlled_Code\Piasa_VS2008\trunk\ElectronicFileTransfer\ElectronicFileTransfer\bin\Debug\winscp.exe is 5.0.6.2227, product WinSCP version is 5.0.6
[2012-05-02 14:20:23Z] [000a] Exception: WinSCP.SessionLocalException: The version of \\piasa\ClientApps\Programs\SVN_Controlled_Code\Piasa_VS2008\trunk\ElectronicFileTransfer\ElectronicFileTransfer\bin\Debug\winscp.exe (5.0.6) does not match version of this assembly \\piasa\ClientApps\Programs\SVN_Controlled_Code\Piasa_VS2008\trunk\ElectronicFileTransfer\ElectronicFileTransfer\bin\Debug\WinSCP.DLL (5.0.6.0). You can disable this check using Session.DisableVersionCheck (not recommended).
[2012-05-02 14:20:23Z] [000a] ExeSessionProcess.CheckVersion leaving
[2012-05-02 14:20:23Z] [000a] ExeSessionProcess..ctor leaving
[2012-05-02 14:20:23Z] [000a] Exception: WinSCP.SessionLocalException: The version of \\piasa\ClientApps\Programs\SVN_Controlled_Code\Piasa_VS2008\trunk\ElectronicFileTransfer\ElectronicFileTransfer\bin\Debug\winscp.exe (5.0.6) does not match version of this assembly \\piasa\ClientApps\Programs\SVN_Controlled_Code\Piasa_VS2008\trunk\ElectronicFileTransfer\ElectronicFileTransfer\bin\Debug\WinSCP.DLL (5.0.6.0). You can disable this check using Session.DisableVersionCheck (not recommended).
at WinSCP.ExeSessionProcess.CheckVersion(String exePath, FileVersionInfo assemblyVersion)
at WinSCP.ExeSessionProcess..ctor(Session session)
at WinSCP.Session.Open(SessionOptions sessionOptions)
[2012-05-02 14:20:23Z] [000a] Session.Cleanup entering
[2012-05-02 14:20:23Z] [000a] Session.Cleanup leaving
[2012-05-02 14:20:23Z] [000a] CallstackAndLock..ctor leaving
[2012-05-02 14:20:23Z] [000a] CallstackAndLock..ctor entering
[2012-05-02 14:20:23Z] [000a] Session.DoDispose entering
[2012-05-02 14:20:23Z] [000a] Session.Cleanup entering
[2012-05-02 14:20:23Z] [000a] Session.Cleanup leaving

Reply with quote

Advertisement

You can post new topics in this forum