1

I'm trying to use a 3rd party DLL (WinSCP .NET assembly) in Dolphin 6.1b2. I've registered the DLL and generated a TypeLib in Windows 7.

In Dolphin I successfully used the component wizard to generate the interfaces but when I try to register the control and TypeLib I get errors. On the registering the control I get

WinSCPnet.dll was loaded but DllRegisterServer entry point could not be found.

Does anyone have any idea why it's failing? I have also asked the author of the DLL and he's leaning toward a Dolphin problem since the registration worked in Windows.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Duetto
  • 9
  • 3

1 Answers1

2

The DLL is a .NET assembly, import the generated TLB.

Downloaded ".NET assembly/automation package" from: https://winscp.net/eng/download.php

Unpacked, registered as per included readme_automation.txt.
See also Downloading and Installing WinSCP .NET Assembly

Started fresh Dolphin, imported the .tlb, generated with WinSCP prefix (so the classes wouldn't start with _).

Opened workspace, imported the WinSCP_Constants Pool, converted start of the C# example (https://winscp.net/eng/docs/library#example):

opts := WinSCP_SessionOptions new
            protocol: Protocol_Sftp;
            hostName = 'example.com';
            userName: 'user';
            password: 'mypassword';
            sshHostKeyFingerprint: 'ssh-rsa 2048 ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff';
            yourself.

Got working object back ...

EDIT: Your WinSCP forums notion "in order to use it within dolphin you need to have its tools register the dll and tlib" is wrong. The COM "source" needs to be registered only once (In case of "old-school" COM server, you can either use regsvr32 or dolphin - both does the same; in case of .NET assembly you have to use the .NET incantation). Only thing really needed on dolphin side is to import previously registered library.

If there is .TLB, I'd go for .TLB, otherwise try my luck with .DLL. Sadly, for some standard COM interfaces Microsoft never made typelibs available, so it's even worse there (use C/C++, or create struct/interface tables by hand).

Edit 2 - further questions:

1) can you explain the relationship between the typelib and the library class which "i create" ( i.e. dolphin tutorial in help)

Dolphin creates smalltalk classes to mirror the COM types / structures. You use these to instantiate COM types from Smalltalk, call their methods, pass them (and also primitive types such as strings, integers, ...) as arguments and get Smalltalk types for returned values (Dolphin does all the conversions for you, so you can +- forget you are calling foreign code).

2) an example of the method you implemented mapping the library class to the winscp interface.

I implemented nothing, I just used the generated wrapper (in background, WinSCP COM object - SessionOptions - got created, and had some properties set).

basically, i just said:

var opts = new WinSCP.SessionOptions().
opts.Protocol = Protocol.Sftp;
opts.HostName = .........

Just look at WinSCP Automation documentation / examples, and then convert it to smalltalk-speak (and hopefully, it should auto-magically work ;-).

3) where are the smalltalk methods protocol:, hostName:, etc defined? i searched the image and they are not there. how did you know to use those method names?

Since SessionOptions (represented by [PREFIX]_SessionOptions class in Dolphin) is an IDispatch interface (subclass of IDispatch in Dolphin), all the method calls are dynamic in nature. You just do the right things (& catch possible failures at necessary granularity), and it will "just work (tm)".

Smalltalk sibbling is the #doesNotUnderstand: aMessage method.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Miloslav Raus
  • 747
  • 6
  • 9
  • PS: I'm not gonna subscripbe to WinSCP forums where you also asked, if it's this, post it there ... – Miloslav Raus Jul 14 '16 at 14:57
  • miroslav, i followed your instructions and example and did get back a valid instance. thanks! – Duetto Jul 14 '16 at 17:47
  • miroslav, 1) can you explain the relationship between the typelib and the library class which i create ( i.e. dolphin tutorial in help) 2) an example of the method you implemented mapping the library class to the winscp interface. – Duetto Jul 14 '16 at 17:50