Clarion and .Net Integration

Tags: #<Tag:0x00007f98bcd10770>


I’m new with development in Clarion, I’m learning due to the company I work for, but I still do not know many things.
I would like to know what the possibilities of integration between Clarion and .Net, for example, there is a Clarion plugin for VSCode, what is it? And what are the advantages of working with Clarion and .Net?
And if you have some interesting materials on this subject for beginners I would appreciate it.
Thank you very much!

eBook: Using .NET assemblies in Clarion for Windows

1 Like

Thank you very much, Mike_Douglas!

Also, check out this topic in ClarionHub.

And search in the old Clarion Magazine archives.

It’s also possible to call .NET methods from Clarion directly, without COM. You just need to create unmanaged exports of .NET methods you want to use from Clarion.
Next, using WinApi you need to load the DLL dynamically (instead of creating LIB, as described here), get the address of the method and finally call it in Clarion. WinApi functions: LoadLibraryA, GetProcAddress and eventually FreeLibrary.

For these dynamically loading and call of methods you will need to use some trick in Clarion. You must declare a prototype of the method (like for WinApi functions) and a variable of type LONG with an external name exactly the same as the method’s label declared in Clarion (this label in Clarion does not have to be the same as the method name in .NET). The variable will hold the address of the method read using the GetProcAddress function.
AddressOfMyMethod LONG,NAME(‘MyNetMethod’)

then, using WinApi you have to load your .NET DLL and set the address of the method to this variable AddressOfMyMethod and as the last step you can call your method from Clarion like this: MyNetMethod().

This way you can return a value from the .NET method, use output parameters or even open a window created in .NET.

We can utilize windows created in .NET (WPF) injected into empty Clarion windows - thanks to this, .NET windows behave identically to other windows created in Clarion. We use this solution successfully on production in a large, multi dll, MDI application, but this is a bit too complicated and also requires using some advanced techniques in .NET to describe the details here. :wink:


just wondering, is it possible using this method get an access to non-static data/instance? For example, if I have C# code:

  // 3 local instances
  MyClass mc1 = new MyClass(1);
  MyClass mc2 = new MyClass(2);
  MyClass mc3 = new MyClass(3);

I want to get in Clarion a paramter from 2nd instance:

`  m2.GetParam(&p)  // returns 2

Hi Mike,

we export from .NET only static methods, but they usually internally call methods on object instances.
Sometimes identifier of the instance comes from Clarion as a parameter and sometimes it is deduced in the logic on .NET side.