C# and C++ need help

Discussion forum about all things Gupta, OpenText and the community.
TWitte
Germany
Posts: 10
Joined: 06 Nov 2017, 13:07
Location: Unterhaching

C# and C++ need help

Post by TWitte » 11 May 2020, 09:40

Hi everyone,

I was wondering how a simple example of an exported function would look like in c# and c++.
I have made serveral tries, but I was not able to export a simple math function like c = a + b return c and import that in a naked apl.

Could anyone help me out?

Thank you in advance.

Timo
Timo Witte
BPCS Consulting Services

isential
Germany
Posts: 14
Joined: 05 Jul 2017, 15:18
Location: Germany

Re: C# and C++ need help

Post by isential » 12 May 2020, 09:46

Hello Timo!

The C or C++ interface is relatively well documented, even if parts of some manuals are from the last century.

What we did not manage to do in a stable way was to integrate C# via C++ (C++/CLI) into SAL:

SAL (TD Win 32) <==> C++ (C++/CLI) <==> C#

Has anyone succeeded in integrating self-made C#.NET libraries into SAL using C++/CLI?

isential
Germany
Posts: 14
Joined: 05 Jul 2017, 15:18
Location: Germany

Re: C# and C++ need help

Post by isential » 12 May 2020, 14:11

You can forget my previous mail.Sorry! It refers to the inclusion of .NET in the old version 1.1.2. We wanted to upgrade this old version a bit, but we finally gave up on that.

thomas.uttendorfer
Site Admin
Site Admin
Germany
Posts: 194
Joined: 05 Mar 2017, 17:19
Location: Munich Germany

Re: C# and C++ need help

Post by thomas.uttendorfer » 12 May 2020, 17:07

Hi Timo,

with TD6 or newer (maybe also TD5) it is possible to write code in C# and call that from TD.
Here are the sample projects for VisualStudio and TD:
CSharp4Td.zip
In short I did the following:
1) Create a Class Library Project (.NET Framework) with a class and a method
2) Build the dll
3) With TD: Start the .NET-Explorer and create the wrapper .apl
4) Import the wrapper .apl into your TD-project
5) Instantiate the .NET-class and call the method

Regards
Thomas
You do not have the required permissions to view the files attached to this post.
Thomas Uttendorfer
[ frevel & fey ] Software-System GmbH
https://thomasuttendorfer.wordpress.com/

isential
Germany
Posts: 14
Joined: 05 Jul 2017, 15:18
Location: Germany

Re: C# and C++ need help

Post by isential » 13 May 2020, 06:02

Reference to TD 6.2:

Yeah, that's it. But it gets funnier if you have different DLLs that you want to include with the .Net-Explorer... That can take a lot of work and nerves. There are several solutions for this, but none really satisfies you if you develop the DLLs yourself.

Also the way in which the DLLs are included is nothing else than the inclusion of a grave of methods... This has nothing to do with object-oriented programming.

You can use a TD wrapper to include the DLLs and then delete almost everything that the .Net-Explorer invented after the inclusion, so that the global part is only present once, or you can move everything to the C# side.

On the C# side, you can work with ILMerge, which we have discarded for various reasons, or you can make your own wrapper in C#, which includes the .Net DLLs and only shows the methods you want to make available to TD. This is what we finally decided to do.

However, everything still remains a grave of methods or functions - no trace of object-oriented programming. Better than pure C++ DLLs, but from the last century. So really big projects are not really feasible, let alone maintainable.

TWitte
Germany
Posts: 10
Joined: 06 Nov 2017, 13:07
Location: Unterhaching

Re: C# and C++ need help

Post by TWitte » 13 May 2020, 07:16

Good morning Thomas,

that is what I was looking for. Thank you very much for your help.

Timo
Timo Witte
BPCS Consulting Services

User avatar
markus.essmayr
Site Admin
Site Admin
Austria
Posts: 1024
Joined: 06 Mar 2017, 06:07
Location: Austria

Re: C# and C++ need help

Post by markus.essmayr » 25 May 2020, 18:29

Hi,

even you already found a solution I wanted to say, that I've successfully created a C++/CLR DLL that integrates well with TD and calls .NET components on the other side.
If you're still interested I could publish a blueprint on how to do that.

Max
Markus Eßmayr
teamdeveloper@t-mx.com

isential
Germany
Posts: 14
Joined: 05 Jul 2017, 15:18
Location: Germany

Re: C# and C++ need help

Post by isential » 25 May 2020, 19:51

As I wrote before, we had tried this for version 1.1.2. But that would have been a grave of functions as well. With the newer versions this is not necessary, because you can directly integrate .NET. SAL <==> C++ <==> C# will surely work with today's versions, but it makes little sense.

Nevertheless, I would be very interested to know what your solution looks like.

Best regards and stay healthy!

René

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 0 guests