Hi all,
I need to use a DLL written with c#.
Can I use it directly on Lianja?
thanks
Fabio
Hi all,
I need to use a DLL written with c#.
Can I use it directly on Lianja?
thanks
Fabio
Hi Fabio,
No. .net dlls requires the .net clr.
They are not the same as normal (unmanaged) windows dlls.
One solution is to create your own .net dll and enable COM Interop. That should then be able to be used with ActiveX.
See microsoft doc,
https://docs.microsoft.com/en-us/dot...ponents-to-com
Last edited by barrymavin; 2020-01-30 at 23:22.
Principal developer of Lianja, Recital and other products
Follow me on:
Twitter: http://twitter.com/lianjaInc
Facebook: http://www.facebook.com/LianjaInc
LinkedIn: http://www.linkedin.com/in/barrymavin
Hi Fabio,
Here is how I managed to use C# DLL with a little help of VFP (desktop app):
https://www.lianja.com/community/sho...nja-Workaround
Josip
Hi Josip,
As I pointed out in that old thread.
This thread in stack overflow may help you create a .net dll that is properly enabled for COM Interop.
http://stackoverflow.com/questions/7...erop-component
EDIT: ComVisible(true) needs to be on the class AND the methods.
http://blogs.msdn.com/b/asiatech/arc...trol-in-c.aspx
If you SET DEBUG ON and issue a createObject("...") in the console you can look in the debug file. Chances are the methods are not decorated properly, but that's not a show stopper, there is a another way to call those methods...
obj = createObject("...")
obj.dynamicCall( args... );
Last edited by barrymavin; 2020-01-31 at 02:46.
Principal developer of Lianja, Recital and other products
Follow me on:
Twitter: http://twitter.com/lianjaInc
Facebook: http://www.facebook.com/LianjaInc
LinkedIn: http://www.linkedin.com/in/barrymavin
Hi Barry, thanks for your suggestion, now I try to read the MS doc.
meanwhile, I'm tryng the Josip sulution.
I've created the project and compiled the DLL on my VFP machine and the sample work fine:
Now, I've copied vfpcomserver.* files to my Lianja Dev machine, into "C:\lianja\library" folder.Code:ox = CreateObject("vfpcomserver.vfpcom") && create the server object ? "Time from server:" + ox.evalexpr("time()") && get the record count
then I've try to:
but I get this error:Code:set defa to C:\lianja\library ox = CreateObject("vfpcomserver.vfpcom")
Fri Jan 31 01:49:03 2020
**** Lianja error ****
ox = CreateObject("vfpcomserver.vfpcom")
^
CLASS 'vfpcomserver.vfpcom' not found
what I'm wrong?
thanks
Fabio
Hi Fabio,
This solution is for
DO vfpcomserver.prg
on the same machine where you will CREATEOBJ and use it.
VFP was doing COM registration with regsvr32 for you.
Otherwise, you need to manualy register this COM DLL on the new machine with copied dll.
Something like that:
"%~d0\gacutil.exe" /i "%~d0\Interop.vfpcomserver.dll"
"%SystemRoot%\Syswow64\regsvr32.exe" /i /s "%~d0\vfpcomserver.dll"
(check where your gacutil.exe and regsvr32.exe are located. Be aware of tilda simbols right after %, not hyphen as forum post automatically transcribes.)
Last edited by josipradnik; 2020-01-31 at 04:24.
Steps:
In VFP
... after DO BUILDVFPCOM.PRG in VFP console (see time shown)
...testing the object in VFP:
Using it in Lianja console
And C# (DLL) code was:
![]()
Last edited by josipradnik; 2020-01-31 at 04:18.
Hi Josib,
many thanks, I try as soon as possible.
Hi Barry,
I had a problem with your second link (maybe because this is MSDN blog, and my MSDN subsription is expired).
For others interested in, here is the correct link:
https://docs.microsoft.com/en-us/arc...x-control-in-c
I did not know about dynamicCall function.
In this scenario I can get it to work in Lianja if it is the procedure in VFP code without parameters (not for .NET part):
D:\Program Files (x86)\Microsoft Visual FoxPro 9\Code:ox2 = CreateObject("vfpcomserver2.vfpcom2") && create the server object ?ox2.dynamicCall('foxproc1') && proc without parameters, with HOME(1)
But not when there are parameters (foxproc2) no matter how I define types of parameters, as strings or as integers.
The result is always
.F.
As I mentioned, you need to SET DEBUG ON before you issue the createObject(). The method signatures can be seen in the debug file. The signature is the firstly parameter to dynamicCall().
By looking at the signatures you can see what the ActiveX exposes.
Principal developer of Lianja, Recital and other products
Follow me on:
Twitter: http://twitter.com/lianjaInc
Facebook: http://www.facebook.com/LianjaInc
LinkedIn: http://www.linkedin.com/in/barrymavin
Bookmarks