This package contains project templates used to created Brokered Windows Runtime Components and their Proxy Stubds, which enables side-loaded modern applications to communicate with pre-existing desktop components.
This solution works on Windows 8.1 update or later version.
It contains two project templates:
1. A C# project template for you to create the Desktop Windows Runtime components that are used to bridge modern application and pre-existing desktop code.
2. A C++ project template to generate the IPC proxy stub that will be used in your modern application.
For more details about the Brokered Windows Runtime Component, please review whitepaper on MSDN:
http://msdn.microsoft.com/en-us/library/windows/apps/dn630195.aspx
Here is a brief guidance on how to use the template to create a brokered WinRT component:
Create a new Brokered WinRT Component using the Templates -> Visual C# -> Brokered Windows Runtime Component (Let’s call thisBrokeredComponent)
Make updates to Class.cs (change file name if needed) to define the component.
Add a new project to the existing solution to create proxy/stub for this using the Templates -> Visual C++ -> Brokered Windows Runtime ProxyStub. (Let’s call this BrokeredProxyStub)
Add project reference on theBrokeredProxyStub project to depend on BrokeredComponent.
Build the entire solution to see if the build is successful.
Run regsvr32 to register theBrokeredProxyStub.dll found in $(SolutionDir)\[Debug|Release] folder.This step can be omitted if you perform steps described in NOTE.
Create a Windows Store C# App in the same solution.
Add a project reference on the C# App to depend on theBrokeredProxyStub project.
Update the AppxManifest to specify where the definition of the Brokered component is using this XML
<Extensions>
<ExtensionCategory="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>clrhost.dll</Path>
<ActivatableClassActivatableClassId="[Fully Qualified Name of Brokered Component]"ThreadingModel="MTA">
<ActivatableClassAttributeName="DesktopApplicationPath"Type="string"Value="[Path to location of Brokered Components and ProxyStub]" />
</ActivatableClass>
</InProcessServer>
</Extension>
</Extensions>
Update code in the Windows Store C# App to use the brokered WinRT Component
Run the Store App and see the code run
NOTE:
If you run Visual Studio as Administrator and mark the Proxy/Stub to register automatically using “project/properties/Linker/General/Register Output” of BrokeredProxyStub project (shown below) then things are 100% automatic. i.e. step 6 is no longer required.