Search code examples
c#.netvisual-studio-2010windows-runtimewinrt-component

Not able to use WinRT Libraries in my Visual basics 2010 C# project


So, I've been trying to get access To PackageManager class from namespace Windows.Management.Deployment from Windows Runtime which is used to fetch the details of Metro Apps installed in the system.

Its been told that using WinRT libraries for the Desktop application so that I can refere those in my project.

After following the procedures from this walkthrough, I should have been able to add reference to Windows.Management.Deployment namespace in my project. But, when I am trying to change the TargetPlatformVersion in *.csproj file as given in the above blog I am getting the below error.

My Result

Also, in Reference Manager dialog box as shown in the above link, there is a Windows Tab where the required library is available.

But my Reference Manager is as below: Reference Manager

I noticed that all the procedures are done Visual Studio 2012 + while I am doing my project in 2010 version. Also the .NET Framework version that is being used in the procedure is 4.5(default for VS2012) while I am using version 4.0 ( default for VS2010). Does any of these have anything to do with the problem I am facing?

Please bear if I am doing some obvious mistake and guide me through this issue. Thank You.


Solution

  • After a little research I came to a conclusion and would like to share it. The compatible .NET version for Visual Studio 2010 is .NET 4.0. But the attribute is defined only after version .NET version: 4.5. That is the reason why I am not able to get windows tab in my AddReference Dialog box. These windows tab are applicable for only Microsoft Visual Studio 2012 and plus versions. If you want to use WinRT library, use Visual studio 2012 and plus and follow the steps given below

    For c#

    For C_++

    In case if you don't want to spend time in upgrading to Visual Studio 2012, you can do this in 2010 itself by manually changing all the necessary .winmd file into .dlls and then including them into your code.