Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Active Contributor
Since a few days I try the possibilities of Microsoft .NET Core development platform. Therefore I downloaded the current release 3.1 of the .NET Core SDK and runtime. In this context I read a very interesting post about exposing .NET Core components to COM. The SAP GUI for Windows offers with its OLE interface the possibility to use COM libraries. I've already described this in a post with Python programming language. And now I was very interested to see if and how it works with .NET Core.

I used the command line interface (CLI) of dotnet only, no IDE.

  1. I created a new folder and in that folder I ran the following command:
    dotnet new classlib --framework netcoreapp3.1

  2. According to the description in the post, I made the additions in the source code, with a few changes: The ComInterfaceType must be Dual for late binding and I added a ProgId.

    using System;
    using System.Runtime.InteropServices;

    namespace Test {

    public interface ITest {

    string retHello();


    public class Class1 : ITest {

    public string retHello() {
    return "Hello World";



  3. In the csproj file I added the EnableComHosting tag.

    <Project Sdk="Microsoft.NET.Sdk">



  4. Now I builded the library with the CLI
    Important is here the runtime argument, it must be win-x86, this is the architecture of the current SAP GUI for Windows.

    dotnet build --configuration release --runtime win-x86

  5. Then I registered the comhost library and from this point it can be used in ABAP.
    regsvr32 Test.comhost.dll​

  6. Here a tiny ABAP report.
    Report Z_COM_TEST.

    oTest Type OLE2_OBJECT,
    Result Type String.

    Create Object oTest 'Test.Class1'.
    Check sy-subrc = 0 And oTest-Handle <> 0 And oTest-Type = 'OLE2'.
    Call Method Of oTest 'retHello' = Result.
    Write: / Result.


This example is not very inventive, but it shows very good how easy .NET Core can be used from ABAP. And should the SAP GUI for Windows also exist in a 64-bit version in the future, we simply change the runtime option to win-x64.

Labels in this area