SAP GUI Connection not working after update to .NET 6

489 views Asked by At

I developed a .NET 4.6 Framework project (X64) with access to the running sap-instance. to connect to sap i used the exactly same way as the SAP-Script:

Script-Version:

Set SapGuiAuto  = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
...

.Net Framework 4.6.2 / .Net6 Version:

Dim SapGuiAuto  = GetObject("SAPGUI")
Dim application = SapGuiAuto.GetScriptingEngine`
Dim SAPCONN = application.connections(0)
Dim SAPSESS = SAPCONN.children(0)
SAPSESS.findById("wnd[0]").ElementVisualizationMode = False

In .NET Framework 4.6, I got access to an SAP system and the connection was working.

Now I updated to .NET 6 and the first code line (SapGuiAuto) reports this error:

Fehler beim Laden der Typbibliothek/DLL. (0x80029C4A (TYPE_E_CANTLOADLIBRARY))

Second line then crashes because object has no type GetScriptingEngine. It looks like some files are missing but if this would be the case it should not work in .NET 4.6 project.

On the same computer, same installations if I try the same again in .NET 4.6.2, it is still working ... What am I doing wrong? Can it be that GetObject behaves not the same in different framework versions? What can I do to fix this issue?

Thank you in advance for your help!

NB: I already tried to add/and remove the COM libraries (SAPFEwse) from the project but this seems to make absolutely no difference if this is included or not...

I tried also to install the outdated nuget library "SAP.GUI.Scripting.Net". which in fact is just ROT WRAPPER and the SAPFEWSE Library. Also no success with this Library.

1

There are 1 answers

0
Felix Almesberger On

.NET 4.8 and .NET 6 are not compatible, there have been a lot of breaking changes. Basically .NET 5 / 6 / 7 are what has been called .NET Core in the past. The assemblies are not binary compatible. So basically you can't use a .NET 4.8 Assembly (SAP) in .NET 6. Check whether SAP offers a SDK for .NET Core / .NET 5 and above.