To access legacy functionalities and APIs such as .NET APIs, we have a few ways: Using the Named Pipe or socket to interact with the exterior thread; using the runtime broker; Using rpcrt4. In this passage, I will talk about how to use runtime broker in UWP and how to call .NET apis which is not supported in WinRT using brokered WinRT component.

Firstly, we need to get the Brokered WinRT Component template from VS Extension Manager.

Create a new Brokered WinRT Component solution using the template we've just installed.

Modify the name of your server, proxy and client.

Start writing your codes in the Server project. You can use native .net codes such as legacy dlls freely in this project. In this sample, I will choose "BrokeredClass" as the calss name. After implementing your native .net codes, right click the project and select Build and the system will generate the winmd file and a few c code files that need to be added to your Proxy project later on.

Now take a look at your Proxy project. It's lonely here, so let's put some codes in it. Right click the Proxy project, click Add-Existing file, select the c files generated just now (Dlldata.c, Server.h, Server_i.c, Server_p.c)

Build the Proxy project.

A winmd file(Server.winmd) will be generated at (SolutionFolder)\bin\Debug\reference

Add this winmd file as the reference of Client project.

Now try to create an instance of "BrokeredClass" and call the native .NET codes we implemented.