Topic "MS SQL CLR Problem"

Author Message
rke002
[View user's profile]

Joined: 2012-12-19
Posts: 9
Hi, I wrote a CLR procedure. CLR Installation work fine.

Just an execution of this procedure thrown an exception.

Quote:

Msg 6522, Level 16, State 1, Line 4
A .NET Framework error occurred during execution of user-defined routine or aggregate "ext_REMOTE_GET_DIR_INFO":
System.Exception: Cannot locate path of assembly [WinSCP, Version=1.0.4.2881, Culture=neutral, PublicKeyToken=b5f19f5762436b89] neither from its code base [], nor from its location []
System.Exception:
bei WinSCP.Logger.GetAssemblyFilePath()
bei WinSCP.ExeSessionProcess.GetExecutablePath()
bei WinSCP.ExeSessionProcess..ctor(Session session)
bei WinSCP.Session.Open(SessionOptions sessionOptions)
bei SqlNetwork.WinScpClient.WinScpManaged.EnumerateRemoteDir(String directory)
bei SqlNetwork.TabledFunctions.RemoteDirStructure(SqlString id, SqlString dir)
.


Code:

public class WinScpManaged : Abstracts.Ssh
{
    /// <summary>
    /// Get Session Information.
    /// </summary>
    private SessionOptions ConnectionOptions
    {
        get
        {
            return new SessionOptions
            {
                Protocol = (Protocol)this.ProtocolType,
                HostName = this.Host,
                UserName = this.User,
                Password = this.Password,
                SshHostKeyFingerprint = this.HostKey
            };
        }
    }

    private void StartSession(Session session)
    {
        //session.ExecutablePath = @"C:\Program Files (x86)\WinSCP\WinSCP.exe";
        session.DisableVersionCheck = true;
        session.DebugLogPath = @"C:\projects\winscp\winscp.dbg";
        session.SessionLogPath = @"C:\projects\winscp\winscp.log";
        session.Open(this.ConnectionOptions);
    }

    public override IEnumerable EnumerateRemoteDir(string directory)
    {
        using (var session = new Session())
        {
            this.StartSession(session);
            return session.ListDirectory(directory).Files;
        }
    }


WinSCP is installed and it have no effect if i use ExecutablePath or not.

No session has been started, so no output file for session log exists.

Debug output is

Quote:
[2013-01-23 16:30:37.294Z] [000e] CallstackAndLock..ctor entering
[2013-01-23 16:30:37.300Z] [000e] Session.DoDispose entering
[2013-01-23 16:30:37.309Z] [000e] Session.Cleanup entering
[2013-01-23 16:30:37.310Z] [000e] Disposing log readers
[2013-01-23 16:30:37.313Z] [000e] Session.Cleanup leaving
[2013-01-23 16:30:37.356Z] [000e] CPU Load [266,8286%]
[2013-01-23 16:30:37.356Z] [000e] Disposing logger, no more logging


Hm, i do not really know what else to do...

Someone have any idea?

All assemblies are loaded into the Application Domain of the MS SQL Server. I guess, MS SQL load it directly from memory, so this assemblies have not location on the HDD. Sure, if you try to access assembly location so it will be always empty.

It is possible to activate embemed assembly call instead of calling it from path?
Advertisements
rke002
[View user's profile]

Joined: 2012-12-19
Posts: 9
I just want task know if there been any progress resolving this problem.

Thanks
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
This issue has been added to the tracker:
https://winscp.net/tracker/show_bug.cgi?id=970
rke002
[View user's profile]

Joined: 2012-12-19
Posts: 9
As far as I can see, bug was fixed. When will you deploy the 5.1.4 version?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
rke002 wrote:
As far as I can see, bug was fixed. When will you deploy the 5.1.4 version?

I do not have any date set yet, sorry.

Can you please email the debug log I've asked for in the email?
rke002
[View user's profile]

Joined: 2012-12-19
Posts: 9
You should receive mail from me, yesterday. If not, let me know. I have tried with new assemblies but still have the same error. Hmm ConnectionOptions may cause the error... maybe.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
rke002 wrote:
You should receive mail from me, yesterday. If not, let me know.

I haven't received it. Please send again.

Quote:
I have tried with new assemblies but still have the same error. Hmm ConnectionOptions may cause the error... maybe.

Is the callstack the same? Please post it.
rke002
[View user's profile]

Joined: 2012-12-19
Posts: 9
Sorry for late reply. I has one week vocation.

The new assembly seems to work fine.

One question. Is it possible to use WinSCP.exe from embed source?
For example, I'm using WinSCP.dll in new project as reference assembly. If it could work adding WinSCP.exe as embed source in the new project and send all Com calls into this embed assembly.
Would be nice, since i do not have to know where winscp assembly is on the HDD.
So instead of calling ExecutablePath you can give the assembly full name as reference.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
rke002 wrote:
One question. Is it possible to use WinSCP.exe from embed source?
For example, I'm using WinSCP.dll in new project as reference assembly. If it could work adding WinSCP.exe as embed source in the new project and send all Com calls into this embed assembly.
Would be nice, since i do not have to know where winscp assembly is on the HDD.
So instead of calling ExecutablePath you can give the assembly full name as reference.

You would have to extract the .exe from resource to file. Actually you can do this yourself.
rke002
[View user's profile]

Joined: 2012-12-19
Posts: 9
This would work, but if i use CLR implementation for the Database it will fail.

The stupid thing is that i have to define the folder where extracted assembly should be copy on HDD.

Hm, i can extract it into the temp folder and check each time, if the file exists. If not, create new WinSCP.exe. This should work but this solution is not pretty.

Thanks.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License