My C# program accesses SAP via Nco3 (sapnco.dll). This program also needs to work with Delphi. Some of my methods return types from the sapnco.dll:
public void IRfcTable table(...) { ... }
in Delphi this method shows up as
function table(...): IUnknown { ... }
I suppose this IUnknown is because my TLB does not include the sapnco.dll. I tried "Embed Interop Types = true" in Visual Studio, but then this error occurs:
Error Interoptypen aus Assembly "C:\…" können nicht eingebettet werden, weil das ImportedFromTypeLibAttribute-Attribut oder das PrimaryInteropAssemblyAttribute-Attribut fehlt. c:…\sapnco.dll
(Interop Types could not be embedded because some attributes are missing).
Is this the right way? If so, where to put these attributes?
sapnco.dll is a .NET dll, so it is not exposed to COM, so you cannot directly use this types in a COM environment. The solution to your problem is to create a library to wrap the sapnco.dll in COM exposed classes:
As an example:
Then your method must be implemented like: