How to reference Kotlin/Native DLLs from C# code in a Windows/UWP app?

I was able to successfully generate a windows DLL by following instructions here. Although, I haven’t been able to consume the DLL in my C# Windows app and haven’t found any tutorial/blog on how to do so. I have tried following things-

  1. Tried CppSharp tool to auto generate DllImport statements. This ran into a runtime error which might be specific to how Kotlin/Native structures the exports.
  2. Hit and trials at DllImport syntax - none of which worked. Kotlin/Native generates deeply nested structs because of the package structure and it’s not easy to guess how the DllImport syntax should look like.

Does anyone on this forum know how to go about this? Given that Windows has first class support in Kotlin/Native, it would be helpful if there was an official guide on exactly how to consume kotlin native DLLs from C# codebase.

2 Likes