You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to write an out-of-process WinRT component in C#? If it is, some code should probably be added to the sample. If not, this fact should probably be noted in the sample's README.
Also, if there is some documentation on MSDN about writing out-of-process WinRT components, it would be nice if the sample's README linked to it.
Here's a scenario to help frame this issue. Imagine being a developer who has only written Windows Store Apps in C#. Coming across this sample would raise some questions:
I can write WinRT components in C#, can I write out-of-process WinRT components in C#? If not, why not? How is an out-of-process WinRT component different than a normal one? If I know how to write a WinRT component, where can I go to learn about the concepts needed to write an out-of-process one?
Adam Comella
Mircosoft Corp.
The text was updated successfully, but these errors were encountered:
To the best of my knowledge, this is not possible to do directly in in C#. It's likely also not possible in C++ /CX. The issue is that you need to implement an executable that calls CoreApplication.RunWithActivationFactories in start-up. I don't believe the activation factories for C# types are readily exposed to the code within the module.
You could probably achieve the equivalent result by building an in-proc winrt component DLL in C#, and then, based on the sample here, build a wrapper .exe that exposes types from the C# DLL by implementing the required IGetActivationFactory interface and calling DllGetActivationFactory method implemented on the C# DLL. Use LoadPackagedLibrary to load the C# DLL containing the component. You'll need to hand-edit your appx registration to list the components as out-of-proc, rather than in-proc. I haven't tried this. It's a moderate amount of work to put together and you might hit a snag that I haven't considered, but I don't know of a reason why it wouldn't work.
Note that if you need to target Win8, you may need to provide COM proxies as well. To do that, you can use the WinMDIdl tool from the SDK to generate IDL from your C# types. Compile the IDL to create proxies, and add the registration to the manifest. For Win10, metadata-based marshalling implemented in the OS should take care of this for you.
This is in reference to the out-of-process WinRT component sample.
Is it possible to write an out-of-process WinRT component in C#? If it is, some code should probably be added to the sample. If not, this fact should probably be noted in the sample's README.
Also, if there is some documentation on MSDN about writing out-of-process WinRT components, it would be nice if the sample's README linked to it.
Here's a scenario to help frame this issue. Imagine being a developer who has only written Windows Store Apps in C#. Coming across this sample would raise some questions:
I can write WinRT components in C#, can I write out-of-process WinRT components in C#? If not, why not? How is an out-of-process WinRT component different than a normal one? If I know how to write a WinRT component, where can I go to learn about the concepts needed to write an out-of-process one?
Adam Comella
Mircosoft Corp.
The text was updated successfully, but these errors were encountered: