MS SQL CLR Problem

Advertisement

rke002
Joined:
Posts:
9

MS SQL CLR Problem

Hi, I wrote a CLR procedure. CLR Installation work fine.

Just an execution of this procedure thrown an exception.

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)
.

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

[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?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Any Progress?

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

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Current Status,

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?

Reply with quote

rke002

Info

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.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Info

rke002 wrote:

You should receive mail from me, yesterday. If not, let me know.
I haven't received it. Please send again.

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.

Reply with quote

rke002
Joined:
Posts:
9

Seems to work

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.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Seems to work

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.

Reply with quote

rke002
Joined:
Posts:
9

sure

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.

Reply with quote

Advertisement

You can post new topics in this forum