2 instances of wodFTPDCom possible? - WeOnlyDo Discussion board

2 instances of wodFTPDCom possible? (wodFTPServer)

by Hugo, Monday, August 10, 2020, 14:05 (40 days ago)

Hi,

I'm trying to initialise a wodFTPDCom object to run as a SFTP server but when I try to initialize
another object (wodFTPDCom) to run as FTP server (as a fall back), I get the error:
"This operation failed because the QueryInterface call on the COM component for the interface with IID '{6DBFD532-B6F6-4986-A5F2-6D51EBC756B1}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."
It is most likely I(m doing something wrong but before starting to check it, I need to know if it's even possible
to have 2 wodFTPDCom objects.

thanks for the reply!
Hugo

2 instances of wodFTPDCom possible?

by Jasmine, Monday, August 10, 2020, 14:29 (40 days ago) @ Hugo

Hugo,

hi. Sure you can, I don't see why not. If you can explain more how/what you're doing perhaps we could be of better help.

Regards,
Jasmine

2 instances of wodFTPDCom possible?

by Hugo, Monday, August 10, 2020, 15:02 (40 days ago) @ Jasmine

Will try to give as much info as I can!

I have a c# exe which, at startup, creates a SFTP opr FTP server using the wodFTPDCom component.
Here is the code that does that:

1. During the init, there is a call:
this.permanentServerSftpFtp = this.TryStartFtp(this.sftpFtpstring, this.settings.FtpPortSftp, out result)
2. (stripped) code TryStartFtp

private wodFTPDCom TryStartFtp(string sftpFtpstring, int port, out MethodResult result)
{
try
{
// Instantiate, configure and start a WeOnlyDo component for FTP hosting
wodFTPDCom sftpFtpServer = new wodFTPDCom();
sftpFtpServer.LicenseKey = FtpServer.WodLicenseKey;

if (SFTP)
{
// Generate the needed key pair
Interop.WODSSHKeyLib.Keys key = new KeysClass();
key.Generate(Interop.WODSSHKeyLib.SSHKeyTypes.RSAkey, 1024);
sftpFtpServer.Certificate = key;
sftpFtpServer.Protocol = ProtocolsEnum.SFTP;
sftpFtpServer.Authentication = AuthenticationsEnum.authPassword;
}
else
{
sftpFtpServer.Protocol = ProtocolsEnum.FTP;
}

sftpFtpServer.Threads = false;
sftpFtpServer.PasvPort = 20;
this.HookupEvents(sftpFtpServer);
sftpFtpServer.Start(port);
return sftpFtpServer;
}
catch (Exception ex)
{
return null;
}
}
3. This all goes well and after startup, I can connect with a client and fe. download files for both FTP and SFTP mode

4. Now, when the app is started in SFTP mode (SFTP server is running), there is this itf call that executes (stripped code), this calls basically the same start procedure TryStartFtp

public override void StartTemporaryFtpServer(out MethodResult result)
{
try
{
this.temporaryServerFtp = this.TryStartFtp("FTP", this.settings.FtpPortFtp, out result);
}
catch (Exception e)
{
}
}

5. If this itf is called, the exception is thrown on the line 'sftpFtpServer.LicenseKey = FtpServer.WodLicenseKey'
basically the first itf call that is executed on the newly created wodFTPDCom component.

=>

System.InvalidCastException: Unable to cast COM object of type 'Interop.wodFTPDComLib.wodFTPDComClass' to interface type 'Interop.wodFTPDComLib.IwodFTPDCom'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6DBFD532-B6F6-4986-A5F2-6D51EBC756B1}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
at Interop.wodFTPDComLib.wodFTPDComClass.set_LicenseKey(String pVal)
at OMSE.FtpServer.FtpServer.TryStartFtp(String sftpFtpstring, Int32 port, MethodResult& result) in D:\GIT\TXCARE_DEVELOP1\Src\FtpServer\FtpServer.cs:line 503, parameters: System.InvalidCastException:

'

2 instances of wodFTPDCom possible?

by Jasmine, Monday, August 10, 2020, 21:24 (40 days ago) @ Hugo

Hugo,

hi. It's hard to say just by looking at the code without actually running it.

Any chance you can create empty project, same as you're working on, and just add wodFTPServer on it and add two instances "hard coded" to see if that works. If it doesn't, just ZIP it and send to techsupport - at - weonlydo.com so we can check it out.

if that works, you know issue is somewhere in your code.

Jasmine