dotnet new classlib --framework netcoreapp3.1
//-Begin----------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
namespace Test {
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("fe103d6e-e71b-414c-80bf-982f18f6c1c7")]
public interface ITest {
string retHello();
}
[ComVisible(true)]
[Guid("9f35b6f5-2c05-4e7f-93aa-ee087f6e7ab6")]
[ProgId("Test.Class1")]
public class Class1 : ITest {
public string retHello() {
return "Hello World";
}
}
}
//-End------------------------------------------------------------------
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<EnableComHosting>true</EnableComHosting>
</PropertyGroup>
</Project>
dotnet build --configuration release --runtime win-x86
regsvr32 Test.comhost.dll
"-Begin-----------------------------------------------------------------
Report Z_COM_TEST.
Data:
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.
"-End-------------------------------------------------------------------
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 | |
2 |