Topic "SFTP - VBA/Access - Error automation when creating a Session"

Author Message
gerard_dev

Guest


We have downloaded and installed the WinSCP .NET Assembly - and registered it for COM - on a hundred machines, following the same procedure described below.

Configuration :
Windows XP
Access 2003 SP3
WinSCP 5.5.0 (winscp550.zip et winscp550automation.zip) with WinSCP.com, WinSCP.exe and WinSCPnet.dll in the same folder.

We use an Access/VBA program to upload and download files from a SFTP server.
Our code is below :

Registration :
Set WshShell = CreateObject("wscript.shell")
strCommande = """C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" "WinSCPnet.dll" /codebase /tlb"""
WshShell.Run strCommande, 0, True

UN-registration :
Set WshShell = CreateObject("wscript.shell")
strCommande = """C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" "WinSCPnet.dll" /unregister /tlb"""
WshShell.Run strCommande, 0, True

Session options :
Dim mySession As New WinSCPnet.Session
Dim mySessionOptions As New WinSCPnet.sessionOptions
With mySessionOptions
.Protocol = WinSCPnet.Protocol_Sftp
.HostName = strHostName
.PortNumber = lngPortNumber
.SshHostKeyFingerprint = strSshHostKeyFingerprint
.UserName = strUserName
.SshPrivateKeyPath = strSshPrivateKeyPath
End With
mySession.Open mySessionOptions

Registration and un-registration seemed always to work fine, and the Access/VBA program was always able to add a reference to the TLB file.

But for approximately 10 of the 100 machines, we got an "error automation" error (-2146232576 or -2146233321) when creating an instance of the Session class.
On these 10 machines, we have uninstalled and unregistered all the versions of WinSCP.dll and WinSCPnet.dll and reinstalled and re-registered the WinSCP .NET Assembly (5.5.0), but we get always the same "error automation" errors.

What can we do ?
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24995
Location: Prague, Czechia
After unregistering WinSCPnet.dll, try searching Windows Registry for any instance of "winscp" and remove it. That's all I can recommend, without knowing what's different about your 10 machines.
_________________
Martin Prikryl
gerard_dev

Guest


prikryl wrote:
After unregistering WinSCPnet.dll, try searching Windows Registry for any instance of "winscp" and remove it. That's all I can recommend, without knowing what's different about your 10 machines.


Unfortunately, we already had this idea of searching Windows Registry for any instance of "winscp" and removing it, and that did not solve our problem.
And the only difference of the 10 machines with the others is precisely that the DLL can be registered on them but is nevertheless not usable by VBA.

In addition, we noted that the question "13301 automation error VBA " relates to a problem close to ours and was not solved either

Therefore, what can we do ?

Thank you in advance for your assistance.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24995
Location: Prague, Czechia
Do you have the same versions of .NET installed on those 10 as on the others?
_________________
Martin Prikryl
gerard_dev

Guest


1) All these machines use the framework 4.0.

2) To register the DLL, I use “\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe” if it exists, if not “\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe” if it exists, if not, the user is requested to install the framework 4.0.
Do I have to modify this algorithm or is it correct?

3) Do you have any idea of what means the error automation -2146233321 when creating an instance of the Session class ?
For your information, we had also on some machines the error automation -2146232576 when creating an instance of the Session class, and we discovered that this error was caused by the installation of the DLL on a network drive, and this error disappeared with the DLL installed on a local fixed drive.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24995
Location: Prague, Czechia
gerard_dev wrote:
2) To register the DLL, I use “\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe” if it exists, if not “\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe” if it exists, if not, the user is requested to install the framework 4.0.
Do I have to modify this algorithm or is it correct?

Look good to me, but I'm no .NET expert.

Quote:
3) Do you have any idea of what means the error automation -2146233321 when creating an instance of the Session class ?
For your information, we had also on some machines the error automation -2146232576 when creating an instance of the Session class, and we discovered that this error was caused by the installation of the DLL on a network drive, and this error disappeared with the DLL installed on a local fixed drive.

I do not know what these mean.
_________________
Martin Prikryl
aronvanammers
[View user's profile]

Joined: 2015-01-28
Posts: 2
I had this same issue when calling WinSCP through COM on a Win 2012 Server machine.

Googling around showed that the error code 2146232576 / 0x80131700 means the .NET CLR cannot be loaded, a very low-level error: http://stackoverflow.com/a/10513911/81949. Apparently the (right version of) the .NET framework cannot be loaded and the wrapper DLL can't be called.

I was able to solve it as follows by building the WinSCP .NET wrapper from source myself. By default it's targeted to the .NET framework 2.0. I changed the target to 4.5. Using this built version on the target machine and calling it through COM works fine.

Although .NET 4 should be fully backward compatible, in this case probably it isn't.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24995
Location: Prague, Czechia
aronvanammers wrote:
I was able to solve it as follows by building the WinSCP .NET wrapper from source myself. By default it's targeted to the .NET framework 2.0. I changed the target to 4.5. Using this built version on the target machine and calling it through COM works fine.

Thanks for sharing your solution!
_________________
Martin Prikryl
aronvanammers
[View user's profile]

Joined: 2015-01-28
Posts: 2
prikryl wrote:
Thanks for sharing your solution!

And thanks to you for building an amazing tool with well-documented integration options Very Happy
San-san

Guest


prikryl wrote:
aronvanammers wrote:
I was able to solve it as follows by building the WinSCP .NET wrapper from source myself. By default it's targeted to the .NET framework 2.0. I changed the target to 4.5. Using this built version on the target machine and calling it through COM works fine.

Thanks for sharing your solution!


What do you mean "by building the WinSCP .NET wrapper from source myself"?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24995
Location: Prague, Czechia
San-san wrote:
What do you mean "by building the WinSCP .NET wrapper from source myself"?

Download source code and build the binary (.dll) in VS.
https://winscp.net/eng/download.php
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