Imagine a scenario where you have a complex framework of WinRT code that you would like to access from both C++ Metro Apps and C# Desktop Apps.
Is there any way to include WinMD in a non-Metro application?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
UPDATE: This only works with Windows 8. Microsoft disabled this in Windows 8.1.
Yes, there is. The block when attempting to add them via the reference manager appears to be implemented inside Visual Studio itself. Once added, Visual Studio will treat the referenced file as it would any other WinMD file.
NOTE: THIS WORKAROUND IS NOT SUPPORTED BY MICROSOFT!
To add your custom WinMD file to any Non-Metro application you must first ensure that you are targeting .NET 4.5. This will not work with any prior version of the .NET Framework.
Once you are targeting .NET 4.5 unload the project file and open it for editing. Then, add the following code after the last
<PropertyGroup>in the project file:Next, find the
<ItemGroup>that contains your references and add the following:While I cannot guarantee that no problems will arise from doing this, and given that Microsoft has been VERY clear about the fact that regardless of which Framework Profile you are using the CLR is loading the same Assemblies, I strongly suspect that this will not cause any harm.
A note on Class Libraries. If you include your WinMD into a non-Metro Class Library and then reference that library in a non-Metro application; you will be unable to access any of the custom WinRT types that your Class Library exposes without either referencing the WinMD file in your application or providing wrapper types.