0

I have written a Windows App SDK based library using C++/WinRT. When I build that library, I get a dll with and an associated winmd file that describes the types stored in my dll. I then consume that library in a Windows App SDK based app project and things work the way I expect.

But when I compile the app project, both the dll and the winmd file of the library are packaged. My understanding is that the winmd file is required at build time to enable external code to interface with the library. But the packaging seems to imply that the winmd file is also required when the app is running.

Is that the case? Are winmd files required when just running an app?

ackh
  • 1,648
  • 2
  • 18
  • 36
  • 2
    *.winmd* files do not (in general) contain any code, and aren't required at runtime by clients of a library. They are used by build tools to discover types and their respective interfaces only. Though, if you are creating a *library*, then clients of your library will need its accompanying *.winmd* file if they wish to consume it. That may be the reason why the *.winmd* file gets packaged for you. – IInspectable Oct 31 '22 at 08:39
  • @IInspectable Ok, that is how I understood it as well. The idea is to ship an app. That parts of it are implemented in its own `dll` is merely an implementation detail and I do not want anything except the app from using the library which is why I don't want to package the `winmd` file. Strange that it ends up in the app's `AppX` output folder by default. If you post this as the answer I gladly accept it. – ackh Oct 31 '22 at 08:50
  • It's been a decade, but still very poorly documented. And actively being tinkered with. Google "metadata based marshaling" to find some breadcrumbs about it. – Hans Passant Oct 31 '22 at 10:00

1 Answers1

-1

According to Windows Metadata (WinMD) files, these metadata files are used by tools and language projections in order to enable language projection and language projections in the resolution of namespaces and types which need this metadata can be at runtime, compile time or both. As far as runtime concerned, Windows provides APIs to aid this.

YangXiaoPo-MSFT
  • 1,589
  • 1
  • 4
  • 22