{"id":2033,"date":"2010-05-25T17:08:00","date_gmt":"2010-05-25T17:08:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudio\/2010\/05\/25\/visual-studio-managed-multi-targeting-part-2-multi-targeting-in-action\/"},"modified":"2022-10-13T13:02:53","modified_gmt":"2022-10-13T20:02:53","slug":"visual-studio-managed-multi-targeting-part-2-multi-targeting-in-action","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/visual-studio-managed-multi-targeting-part-2-multi-targeting-in-action\/","title":{"rendered":"Visual Studio Managed Multi-Targeting: Part 2: Multi-Targeting in Action"},"content":{"rendered":"<div class=\"WordSection1\">\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">Now that we have gone through some key concepts in the previous <\/span><\/span><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/visual-studio-managed-multi-targeting-part-1-concepts-target-framework-moniker-target-framework\/\"><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">part<\/span><\/span><\/a><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\"> in this series, before we go any further in terms of detailed technical concepts, it would be nice to have some \u201cmental visual model\u201d of how multi-targeting impacts almost all project related scenarios in Visual Studio 2010 and thus benefits the users.<\/span><\/span><\/p>\n<p><a href=\"http:\/\/weblogs.asp.net\/scottgu\/archive\/2009\/08\/27\/multi-targeting-support-vs-2010-and-net-4-series.aspx\"><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">Scott Guthrie\u2019s excellent blog on multi-targeting support in Visual Studio 2010<\/span><\/span><\/a><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\"> covers many of these key benefits and scenarios. Please make sure you read that blog before you continue reading the rest of this series, as those help too in the \u201cmental visual model\u201d that I am aiming to establish with this part.<\/span><\/span><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">The key take away from Scott\u2019s blog that I would like to highlight is that, because of the true multi-targeting support in Visual Studio 2010, being within the same IDE your project can target many different frameworks. This provides incredible productivity advantages in my opinion. So now &#8211; once you move your projects to Visual Studio 2010 &#8211; you can continue working with your projects that are targeted to frameworks earlier than .NET Framework v4.0 without doing anything!<\/span><\/span><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">I would like to add some more scenarios here to enhance the visuals and provide concrete visual examples that we can refer back to for the concepts as we encounter them in the rest of this series:<\/span><\/span><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">(All the example projects below are of the C# project type)<\/span><\/span><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">You will be able to create projects that target .NET Framework v2.0 in Visual Studio 2010<\/span><\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/05\/0537.NPv20.png\" border=\"0\" \/><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">Once the project is created observe the \u2018System\u2019 assembly reference path in the Reference Properties window<\/span><\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/05\/7750.v20SysRefProps.jpg\" border=\"0\" \/><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">The path in the Properties window refers to the \u2018System\u2019 assembly in .NET Framework v2.0 &#8211; to which the project is currently targeted. This ensures the developer is only able to use Types from this particular \u2018System\u2019 assembly in this project &#8211; as opposed to using Types from , say, .NET Framework v4.0\u2019s \u2018System\u2019 assembly.<\/span><\/span><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">Now let\u2019s launch the Add Reference Dialog for this project and go to the .NET tab<\/span><\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/05\/5543.v20ard.jpg\" border=\"0\" \/><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">All the framework assemblies that are available to be referenced in this project come from .NET Framework v2.0; we can tell that by looking at the paths of the assemblies. The Add Reference dialog in Visual Studio 2010 is aware of the framework your project is currently targeted to and only shows assemblies that can be used in that Target Framework. This applies both to framework assemblies and framework extensions shown in the Add Reference dialog. Framework extension assemblies are third-party assemblies registered in the AssemblyFoldersEx.\u00a0 AssemblyFoldersEx will be covered in detail in a subsequent blog.<\/span><\/span><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">There is a common misconception that the assemblies shown in the Add Reference Dialog come from the GAC; this is not only incorrect but also somewhat of an oxymoron. The GAC is a \u2018global\u2019 assembly cache and therefore by definition not aware of a target framework boundary or presence of multiple target frameworks. Assemblies shown in the Add Reference dialog are always enumerated from the reference assembly paths of the target frameworks and <i>never<\/i> from the GAC. Reference assembly concepts will be covered in detail in a subsequent blog.<\/span><\/span><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">We can check the framework the project is currently targeted to, through its Properties page<\/span><\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/05\/8637.v20TFPropPage.jpg\" border=\"0\" \/><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">We can also re-target the project to, say, .NET Framework v4.0 through the Properties page itself<\/span><\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/05\/8867.retargettov40.jpg\" border=\"0\" \/><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">After the re-targeting operation is complete, let\u2019s go and check the Properties page again and confirm that the project is indeed now targeted to .NET Framework v4.0<\/span><\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/05\/0207.v40TFProppage.jpg\" border=\"0\" \/><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">Now let\u2019s go and observe the \u2018System\u2019 assembly\u2019s properties again in the re-targeted project<\/span><\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/05\/0508.v40SysProps.jpg\" border=\"0\" \/><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">You can now see that the Path of the System assembly now comes from .NET Framework v4.0 and now suddenly the additional Types in this assembly is now available to the developer.<\/span><\/span><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">Now if we launch the Add Reference dialog we see that the v2.0 framework assemblies are no longer shown, what we see are the v4.0 framework assemblies \u2013 which we can again tell from their paths<\/span><\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/05\/7127.v40ard.jpg\" border=\"0\" \/><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">The big picture that is emerging from all the examples above is that the whole design-time environment is being constrained and shaped by the target framework that the project is currently targeted to thus protecting the developer from any inadvertent type \u201cleakage\u201d of the types that are not really available in that framework at runtime.<\/span><\/span><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">Similarly users can also create projects that are targeted to the Silverlight framework-family and can work within the perimeters of that design time environment.<\/span><\/span><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">My hope with this visual tour, scenarios and user-benefit-examples in this blog and <\/span><\/span><a href=\"http:\/\/weblogs.asp.net\/scottgu\/archive\/2009\/08\/27\/multi-targeting-support-vs-2010-and-net-4-series.aspx\"><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">Scott\u2019s blog<\/span><\/span><\/a><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\"> is that as we continue on this journey and get into more detailed technical concepts the words there comes alive as you correlate those with these \u201cmental visual models\u201d.<\/span><\/span><\/p>\n<p><b><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">Conclusion<\/span><\/span><\/b><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">This Visual Studio Managed Multi-Targeting series pertains to managed project systems and aims to provide a detailed round-up of all relevant\/related topics. <\/span><\/span><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">Please feel free to use the comment stream to ask questions.<\/span><\/span><\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">Previously, in this series:<\/span><\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/visual-studio-managed-multi-targeting-part-1-concepts-target-framework-moniker-target-framework\/\"><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\">Visual Studio Managed Multi-Targeting: Part 1: Concepts: Target Framework Moniker, Target Framework<\/span><\/span><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: trebuchet ms,geneva;\"><span style=\"font-size: small;\"><b>Binu N. Chacko<\/b> \u2013 Software Developer, Visual Studio Platform Team.\n<b>Biography: <\/b>Binu joined the Visual Studio team during the early stages of Visual Studio 2010. Prior to joining the Visual Studio team in early 2008; Binu spent eight years contributing to Windows XP, Windows 2003, Windows Vista, and System Center Configuration Manager 2007\/R2 products \u2013 within Microsoft. Prior to that \u2013 outside\/before Microsoft &#8211; he worked on helping deliver several versions of Canon\u2019s premier Document Management System product. For Visual Studio 2010, Binu was a key contributor to the extensible multi-targeting core platform, solutions and the VB\/C# project system core platform. Binu lives with his wife and the two joys of his life \u2013 his two sons \u2013 in Seattle, Washington; and loves cricket, soccer, theatre and movies.<\/span><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\";font-size: 10pt;\">\u00a0<\/span><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Now that we have gone through some key concepts in the previous part in this series, before we go any further in terms of detailed technical concepts, it would be nice to have some \u201cmental visual model\u201d of how multi-targeting impacts almost all project related scenarios in Visual Studio 2010 and thus benefits the users. [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":255385,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[155,1029],"tags":[85,5,13],"class_list":["post-2033","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio","category-web","tag-asp-net","tag-csharp","tag-visual-studio-2010"],"acf":[],"blog_post_summary":"<p>Now that we have gone through some key concepts in the previous part in this series, before we go any further in terms of detailed technical concepts, it would be nice to have some \u201cmental visual model\u201d of how multi-targeting impacts almost all project related scenarios in Visual Studio 2010 and thus benefits the users. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/2033","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=2033"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/2033\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/255385"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=2033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=2033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=2033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}