{"id":733,"date":"2011-01-10T14:54:35","date_gmt":"2011-01-10T14:54:35","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vbteam\/2011\/01\/10\/vb-core-new-compilation-mode-in-visual-studio-2010-sp1\/"},"modified":"2024-07-05T12:40:38","modified_gmt":"2024-07-05T19:40:38","slug":"vb-core-new-compilation-mode-in-visual-studio-2010-sp1","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/vbteam\/vb-core-new-compilation-mode-in-visual-studio-2010-sp1\/","title":{"rendered":"VB Core &#8211; New compilation mode in Visual Studio 2010 SP1"},"content":{"rendered":"<p class=\"MsoNormal\"><span><font size=\"3\" face=\"Calibri\">While most servicing releases do not include new functionality, Visual Studio 2010 SP1 introduced an important new compiler feature that enables Visual Basic to target new platforms that were not previously supported.<span>&nbsp; <\/span><span>&nbsp;<\/span>This was mentioned in some of the initial SP1 blog posts such as <\/font><\/span><a href=\"http:\/\/blogs.msdn.com\/b\/jasonz\/archive\/2010\/12\/07\/announcing-visual-studio-2010-service-pack-1-beta.aspx\"><font color=\"#0000ff\" size=\"3\" face=\"Calibri\">Jasonz blog<\/font><\/a><font face=\"Calibri\"><font size=\"3\">.<span>&nbsp;&nbsp;&nbsp; <\/span><\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><span><\/p>\n<p><font size=\"3\" face=\"Calibri\">&nbsp;<\/font><\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span><font face=\"Calibri\"><font size=\"3\">This is a strategic investment by Microsoft in the future of VB.<span>&nbsp; <\/span>This provides VB with an increased agility in the future for new platforms to support Visual Basic.<span>&nbsp;&nbsp; <\/span><\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"MsoNormal\">\n<p><font size=\"3\" face=\"Calibri\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\"><font size=\"3\">This blog provides more information about the feature; let me know if you have more questions. <\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><span lang=\"EN\"><\/p>\n<p><font size=\"3\" face=\"Calibri\">&nbsp;<\/font><\/p>\n<p><\/span><\/p>\n<p class=\"MsoSubtitle\"><em><span><font color=\"#4f81bd\"><font size=\"3\">WHAT IT IS?<\/p>\n<p><\/font><\/font><\/span><\/em><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\"><font size=\"3\"><span>The new command line option \/vbruntime* (with an asterisk) will embed a reduced <\/span><span lang=\"EN\">version of <\/span><span lang=\"EN\">the Visual Basic runtime into the compiled assembly and therefore eliminate the dependency on the VB Runtime assembly since this assembly does not ship on all .Net platforms such as Windows Phone 7 and XNA.<\/p>\n<p><\/span><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><span lang=\"EN\"><font face=\"Calibri\">The feature can be used from the VBC command line compiler or by adding an entry <\/font><\/span><span lang=\"EN\">&lt;VBRuntime&gt;Embed&lt;\/VBRuntime&gt;<\/span><span lang=\"EN\"><font face=\"Calibri\"> into the .vbproj file.<\/p>\n<p><\/font><\/span><\/font><\/p>\n<p class=\"MsoNormal\"><span lang=\"EN\"><font size=\"3\"><font face=\"Calibri\">In general, its intended use is only for specific project templates that target platforms that don&rsquo;t ship with a VB runtime.&nbsp; <\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"MsoSubtitle\"><span lang=\"EN\"><\/p>\n<p><em><font color=\"#4f81bd\" size=\"3\" face=\"Cambria\">&nbsp;<\/font><\/em><\/p>\n<p><\/span><\/p>\n<p class=\"MsoSubtitle\"><span><em><font color=\"#4f81bd\"><font size=\"3\">WHEN SHOULD I USE IT?<\/p>\n<p><\/font><\/font><\/em><\/span><\/p>\n<p class=\"MsoNormal\"><span lang=\"EN\"><font face=\"Calibri\"><font size=\"3\">The simple answer to this is you should never need to use this directly.<span>&nbsp;&nbsp; <\/span>The feature has been implemented to allow Microsoft Partner teams to create Visual Basic project templates for platforms that previously didn&rsquo;t support VB. When such VB project templates eventually become available, you as a VB developer will be able to do File&gt;New Project for the new project types, and \/vbruntime* will be used under-the-hood.<span>&nbsp;&nbsp;&nbsp; <\/span><\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"MsoSubtitle\"><span lang=\"EN\"><\/p>\n<p><em><font color=\"#4f81bd\" size=\"3\" face=\"Cambria\">&nbsp;<\/font><\/em><\/p>\n<p><\/span><\/p>\n<p class=\"MsoSubtitle\"><em><font color=\"#4f81bd\"><font face=\"Cambria\"><font size=\"3\">WHAT&rsquo;S INCLUDED?<\/p>\n<p><\/font><\/font><\/font><\/em><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\"><font size=\"3\">The intention is to provide optimal VB experience for .Net VB users while avoiding the need to deploy to full VB runtime, thus the embedded functionality includes:<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraphCxSpFirst\"><span><span><font size=\"3\">&middot;<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font face=\"Calibri\"><font size=\"3\">Conversion <\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\"><span><span><font size=\"3\">&middot;<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font face=\"Calibri\"><font size=\"3\">VB specific attributes<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\"><span><span><font size=\"3\">&middot;<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font face=\"Calibri\"><font size=\"3\">Support for various VB language features such as error handling (.Net style), foreach loop and string comparison <\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraphCxSpLast\"><span><span><font size=\"3\">&middot;<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font face=\"Calibri\"><font size=\"3\">A few useful constants and VB functions such as Chr and Asc<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font size=\"3\" face=\"Calibri\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoSubtitle\"><em><font color=\"#4f81bd\"><font face=\"Cambria\"><font size=\"3\">WHAT ARE ITS LIMITATIONS?<\/p>\n<p><\/font><\/font><\/font><\/em><\/p>\n<p class=\"MsoNormal\"><span lang=\"EN\"><font face=\"Calibri\"><font size=\"3\">In order to avoid bloating assemblies with functionality that either is not used or no used much, some of the functionality provided in this assembly on the currently supported framework has been omitted.<\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"MsoListParagraphCxSpFirst\"><span lang=\"EN\"><span><font size=\"3\">&amp;\nmiddot;<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><span lang=\"EN\"><font face=\"Calibri\"><font size=\"3\">Legacy VB Functions &ndash; Such as Left, Mid.<\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\"><span lang=\"EN\"><span><font size=\"3\">&middot;<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><span lang=\"EN\"><font face=\"Calibri\"><font size=\"3\">Legacy Like operator<\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\"><span lang=\"EN\"><span><font size=\"3\">&middot;<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><span lang=\"EN\"><font face=\"Calibri\"><font size=\"3\">Old Style VB &ldquo;On Error Goto Error&rdquo; Handling<\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\"><span lang=\"EN\"><span><font size=\"3\">&middot;<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><span lang=\"EN\"><font face=\"Calibri\"><font size=\"3\">Late Binding <\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"MsoListParagraphCxSpLast\"><span lang=\"EN\"><span><font size=\"3\">&middot;<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><span lang=\"EN\"><font face=\"Calibri\"><font size=\"3\">Much of the My Functionality<\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\"><font size=\"3\">Many of these limitations do not apply to developers writing VB code using .Net idioms.&nbsp;For those trying to port existing legacy code over and use this functionality it may require a bit of rewriting to use .NET constructs such as the substring function, Try Catch exception handling and use of framework functions rather than the helper class functionality provided in the My Namespace.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font size=\"3\" face=\"Calibri\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\"><font size=\"3\">The new mode is intended to be used in new platform and new project templates &ndash; but it can be used for existing templates though you may run into problems with code generation that depends on missing functionality.&nbsp;An example of this is Windows Forms Application with the application Framework project option checked.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoSubtitle\">\n<p><em><font color=\"#4f81bd\" size=\"3\" face=\"Cambria\">&nbsp;<\/font><\/em><\/p>\n<\/p>\n<p class=\"MsoSubtitle\"><em><font color=\"#4f81bd\"><font face=\"Cambria\"><font size=\"3\">COULDN&rsquo;T I HAVE PREVIOUSLY DONE THIS WITH OTHER COMPILER SWITCHES?<\/p>\n<p><\/font><\/font><\/font><\/em><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\"><font size=\"3\">It was previously possible to target some of these platforms with some cumbersome workarounds using the existing \/vbruntime- switch.<span>&nbsp; <\/span>It was not an ideal solution and required implementation of a number of additional items in order to make it work.<span>&nbsp;&nbsp; <\/span>This new switch is a simpler more elegant approach that makes it much easier.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font size=\"3\" face=\"Calibri\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoSubtitle\"><em><font color=\"#4f81bd\"><font face=\"Cambria\"><font size=\"3\">DOES THIS MEAN THAT I GET LESS FUNCTIONALITY THAN IF I USE C#?<\/p>\n<p><\/font><\/font><\/font><\/em><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\"><font size=\"3\">From the list of limitations you will see that most of them relate to legacy VB functionality.<span>&nbsp; <\/span>So for developers writing modern .NET code there should be no real difference.<span>&nbsp;&nbsp;&nbsp; <\/span>The exception to this rule may be late binding \/ Dynamic.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font size=\"3\" face=\"Calibri\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\"><font size=\"3\">In C# this was introduced in the 2010 product cycle.<span>&nbsp;&nbsp; <\/span>If the platform that you are targeting does not include the dynamic language runtime then there is no difference as the C# dynamic feature uses this. <span>&nbsp;&nbsp;&nbsp;<\/span>This is the case for many of the existing platforms that this feature is intended to be used on.<span>&nbsp;&nbsp; <\/span>So the lack of late binding \/ dynamic support is consistent across both languages.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font size=\"3\" face=\"Calibri\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\">\n<p><font size=\"3\" face=\"Calibri\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoSubtitle\"><em><font color=\"#4f81bd\"><font face=\"Cambria\"><font size=\"3\">HOW DO I KNOW IT&rsquo;S ACTUALLY DONE ANYTHING?<\/p>\n<p><\/font><\/font><\/font><\/em><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\"><font size=\"3\">To see the effects of using this switch you can create a simple console application and compile it using the new functionality (either command line or project file).&nbsp;&nbsp;To see the embedded use tools such as &ldquo;Reflector&rdquo; or ILDASM to disassemble the assembly. You&rsquo;ll notice that &ldquo;Microsoft.VisualBasic&ldquo; namespace was added to your assembly.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font size=\"3\" face=\"Calibri\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\"><font size=\"3\">You can also see that there is no reference to VB runtime assembly in the in the referenced assembly list in your assembly header. <span>&nbsp;<\/span><\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoSubtitle\">\n<p><em><font color=\"#4f81bd\" size=\"3\" face=\"Cambria\">&nbsp;<\/font><\/em><\/p>\n<\/p>\n<p class=\"MsoSubtitle\"><em><font color=\"#4f81bd\"><font face=\"Cambria\"><font size=\"3\">WHEN SHOULD I USE THIS MYSELF? WHAT IS MICROSOFT&rsquo;S RECOMMENDED BEST PRACTICE FOR USING THE FLAG?<\/p>\n<p><\/font><\/font><\/font><\/em><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\"><font size=\"3\">Most users will never use it themselves directly. It&rsquo;s there only for consumption by people who create project templates &ndash; i.e. mainly just for us to use here in Microsoft. The recommendation is that if you create a project template for a platform where Microsoft.VisualBasic.dll doesn&rsquo;t exist, then use the flag.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoSubtitle\">\n<p><em><font color=\"#4f81bd\" size=\"3\" face=\"\nCambria\">&nbsp;<\/font><\/em><\/p>\n<\/p>\n<p class=\"MsoSubtitle\"><em><font color=\"#4f81bd\"><font face=\"Cambria\"><font size=\"3\">HOW DOES THE RELEASED VB SUPPORT FOR WINDOWS PHONE 7 WORKS?<\/p>\n<p><\/font><\/font><\/font><\/em><\/p>\n<p class=\"MsoNormal\"><font size=\"3\" face=\"Calibri\">The <\/font><a href=\"http:\/\/blogs.msdn.com\/b\/jasonz\/archive\/2010\/11\/29\/announcing-visual-basic-windows-phone-7-support-rtw.aspx\"><font color=\"#0000ff\" size=\"3\" face=\"Calibri\">release of Visual Basic support for windows phone tools 7<\/font><\/a><font size=\"3\"><font face=\"Calibri\"> allows developers to create VB applications that runs on the phone even though the phone does not have VB runtime. This is done by adding to each VB application a VB Core assembly. This solution has a few issues, for example C# applications cannot reference VB class library.&nbsp; <\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><font face=\"Calibri\">We plan to use the VB Core mode for future versions of Windows Phone tools to solve these limitations.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font size=\"3\" face=\"Calibri\">&nbsp;<\/font><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>While most servicing releases do not include new functionality, Visual Studio 2010 SP1 introduced an important new compiler feature that enables Visual Basic to target new platforms that were not previously supported.&nbsp; &nbsp;This was mentioned in some of the initial SP1 blog posts such as Jasonz blog.&nbsp;&nbsp;&nbsp; &nbsp; This is a strategic investment by Microsoft [&hellip;]<\/p>\n","protected":false},"author":260,"featured_media":8818,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[195],"tags":[144,167,180],"class_list":["post-733","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-basic","tag-spotty-bowles","tag-vb2010","tag-windows-phone"],"acf":[],"blog_post_summary":"<p>While most servicing releases do not include new functionality, Visual Studio 2010 SP1 introduced an important new compiler feature that enables Visual Basic to target new platforms that were not previously supported.&nbsp; &nbsp;This was mentioned in some of the initial SP1 blog posts such as Jasonz blog.&nbsp;&nbsp;&nbsp; &nbsp; This is a strategic investment by Microsoft [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/733","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/users\/260"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/comments?post=733"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/733\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media\/8818"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media?parent=733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/categories?post=733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/tags?post=733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}