{"id":4773,"date":"2008-01-19T11:01:00","date_gmt":"2008-01-19T11:01:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vbteam\/2008\/01\/19\/source-code-of-visual-basic-runtime-has-been-released-to-public-vladimir\/"},"modified":"2024-07-05T14:34:23","modified_gmt":"2024-07-05T21:34:23","slug":"source-code-of-visual-basic-runtime-has-been-released-to-public-vladimir","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/vbteam\/source-code-of-visual-basic-runtime-has-been-released-to-public-vladimir\/","title":{"rendered":"Source code of Visual Basic runtime has been released to public. (Vladimir)"},"content":{"rendered":"<blockquote>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\"><\/font>&nbsp;<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">One of the things we have been working on recently&nbsp;was publishing sources of VisualBasic runtime library. I am very excited to announce that the sources of VB runtime (Microsoft.VisualBasic.dll)&nbsp;are publicly available now!&nbsp;<span>&nbsp;<\/span>This is a part of a more general work on making .Net Framework sources available to public ( <\/font><a href=\"http:\/\/weblogs.asp.net\/scottgu\/archive\/2007\/10\/03\/releasing-the-source-code-for-the-net-framework-libraries.aspx\"><font face=\"Calibri\" size=\"3\">http:\/\/weblogs.asp.net\/scottgu\/archive\/2007\/10\/03\/releasing-the-source-code-for-the-net-framework-libraries.aspx<\/font><\/a><font face=\"Calibri\" size=\"3\"> ). <\/font><font face=\"Calibri\" size=\"3\">The most important result of this is that developers can <em>see and debug through VB runtime code<\/em>. <\/font><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">There is a very detailed description on how to set up VS debugger so that it could use framework sources (that includes VB runtime too). <\/font><a href=\"http:\/\/blogs.msdn.com\/sburke\/archive\/2008\/01\/16\/configuring-visual-studio-to-debug-net-framework-source-code.aspx\"><font face=\"Calibri\" size=\"3\">http:\/\/blogs.msdn.com\/sburke\/archive\/2008\/01\/16\/configuring-visual-studio-to-debug-net-framework-source-code.aspx<\/font><\/a><font size=\"3\"><font face=\"Calibri\"><span>&nbsp; <\/span>. The article also describes possible issues and workarounds. For most cases&nbsp;everything should work fine, but in case if you have problems, you can refer to this article.<\/font><\/font><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\"><\/font>&nbsp;<\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Let\u2019s see some examples how this functionality can be used.<\/font><\/p>\n<\/blockquote>\n<p class=\"MsoListParagraphCxSpFirst\"><font face=\"Calibri\" size=\"3\"><strong>Debugging without runtime sources (normal case)&nbsp;.<\/strong><\/font><\/p>\n<p class=\"MsoListParagraphCxSpMiddle\"><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<p class=\"MsoListParagraphCxSpLast\"><font face=\"Calibri\" size=\"3\">I have created a simple VB app with a latebound call and then I have started a debugging session and stopped inside the function. Normally VS tries not to bother user with details of such calls and in the call stack it simply says &#8220;[External Code]&#8221;.<\/font><\/p>\n<p class=\"MsoNormal\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2008\/01\/image001.png\"><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<blockquote>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\"><strong>Disabling \u201cJust My code\u201d.<\/strong><\/font><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\"><span>Next step is disabling \u201cJust My code\u201d in debug options so that you could see calls that are not part of your code.<\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><span><img decoding=\"async\" height=\"375\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2008\/01\/image003.png\" width=\"644\"><\/span><\/p>\n<p class=\"MsoNormal\"><span><\/span>&nbsp;<\/p>\n<blockquote>\n<p class=\"MsoNormal\"><span>After disabling \u201cJust My code\u201d in debug options, you will notice that were couple calls performed before we reached the target function. Indeed since compiler does not know at compile time what function will be called it delegates the call to the latebound call support in the runtime library. What we see on the stack in between our functions is the code in VB runtime library. At this point these stack frames are grayed out and pretty much useless as VS does not have sources that correspond to these frames. Double clicking causes this message:<\/span><\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><span><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2008\/01\/image005.png\"><\/p>\n<p class=\"MsoListParagraph\">&nbsp;<\/p>\n<blockquote>\n<p class=\"MsoNormal\"><strong>Configre source location information<\/strong><\/p>\n<p class=\"MsoNormal\">Now, since the sources of Microsoft.VisualBasic are now published we can tell VS where to get them. For that we will use source server support in VS. <br \/>(note that for this to work you will need to make sure you have installed the following QFE <span lang=\"EN\"><a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/Downloads\/DownloadDetails.aspx?DownloadID=10443&amp;wa=wsignin1.0\" target=\"_blank\" rel=\"noopener\"><font color=\"#0000ff\">Visual Studio 2008 QFE<\/font><\/a> as this hotfix updates a debugger component that fetches the source files).<\/span><\/p>\n<p class=\"MsoNormal\"><span lang=\"EN\"><\/span>1.<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>In Visual Studio 2008 and select Tools -&gt; Options -&gt; Debugging<br \/>2.<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>On the \u201cGeneral\u201d Tab<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Uncheck \u201cJust My Code\u201d<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b.<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Check \u201cEnable Enable Source Server Support\u201d<\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2008\/01\/image007.png\"><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<blockquote>\n<p class=\"MsoNormal\">Here we will tell VS where the sources are located and where to cache them locally. The caching is important when sources are accessed from a remote server as it is much faster to get sources from a local cache.<\/p>\n<p class=\"MsoNormal\">On the \u201cSymbols\u201d tab<br \/>a.<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Click the \u201cnew\u201d icon and enter: <a href=\"http:\/\/referencesource.microsoft.com\/symbols\">http:\/\/referencesource.microsoft.com\/symbols<\/a><br \/>b.<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Check \u201cSearch the above locations only when symbols are loaded manually\u201d<br \/>c.<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Enter a path in the textbox in which to cache symbols.<span>&nbsp; <\/span>Make sure this is somewhere that your user account has permissions to write to (for example d:symbols)<br \/>d.<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Hit OK<\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2008\/01\/image009.png\"><\/p>\n<blockquote>\n<p class=\"MsoNormal\">Right click the first runtime frame and select \u201cLoadSymbols\u201d. Wait for symbols to load (may take a moment or two and the first time it will also ask to agree with EULA). Doubleclick the first runtime frame\u2026 What a difference!!! We can see the runtime code.<br \/>(at thirst it may take some time as VS is fetching sources from a remote server, but once they are in the cache it will not do it again)<\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2008\/01\/image011.png\"><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<blockquote>\n<p class=\"MsoNormal\"><strong>Setting breakponts inside VB runtime.<\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\">Even more &#8211; We can F11 through the runtime code and set breakpoints. If you are very curious, you can set a break point at the beginning of the latebound call helper and restart your project. Once you hit the breakpoint you can F11 through latebinder code to see how it was implemented.<\/p>\n<p class=\"MsoNormal\">Note that there is one caveat \u2013 while the sources on the server contain the same code as original sources they are not \u201cexactly&#8221; the same. They have small changes such as copyright banners at the end etc. As a result VS complains about source difference. <\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2008\/01\/image013.png\"><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<blockquote>\n<p class=\"MsoNormal\">This can be safely dismissed by right clicking the breakpoint, opening \u201cLocation\u201d menu and selecting \u201cAllow source file&nbsp;to be different from the original location\u201d. Tere is a way to do this globally, but I would not recommend this since this would affect all you projects.<\/p>\n<p class=\"MsoNormal\">Also to make sure that symbols are loaded before execution gets to the breakpoint, you will need to disable \u201cmanual only\u201d loading for symbols. <\/p>\n<p class=\"MsoNormal\">This will cause all the symbols to be loaded on demand and that includes many .NET FX libraries so this may take some time when you launch debugging session.<\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2008\/01\/image015.png\"><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<blockquote>\n<p class=\"MsoNormal\">This will cause all the symbols to be loaded on demand and that includes many .NET FX libraries so this may take some time when you launch debugging session. After symbols are loaded you should be able to hit the breakpoint in the runtime.<\/p>\n<\/blockquote>\n<p class=\"MsoNormal\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2008\/01\/image017.png\"><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<blockquote>\n<p class=\"MsoNormal\"><strong>What is inside MsgBox<\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p class=\"MsoNormal\">Another interesting scenario that should work now is F11 into VB runtime functions. One that I use the most seems to be MsgBox so let\u2019s take a look what is inside. <br \/>In a hello world project we can set breakpoint on the call to MsgBox.<\/p>\n<\/blockquote>\n<p class=\"MsoNormal\">&nbsp;<img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2008\/01\/image019.png\"><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<blockquote>\n<p class=\"MsoNormal\">When breakpoint is hit just do F11. Wow!! Now we are inside MsgBox and can step through it to see how it works.<\/p>\n<\/blockquote>\n<p class=\"MsoNormal\">&nbsp;<img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2008\/01\/image021.png\"><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">Known issues, FAQ<\/p>\n<p class=\"MsoListParagraphCxSpFirst\"><span><span>1)<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span>Accessing remote symbols is not very fast. This causes delays in VS when sources are fetched. Even with caching enabled in some scenarios VS checks whether information is current. You may get around this by going to Tools -&gt; Options -&gt; Debugging -&gt; Symbols configuration and unchecking<span>&nbsp; <\/span>\u201cSearch the above locations when symbols are loaded manually\u201d checkbox and then debug you project. It may take some time to load all sources (including various .Net libraries) in this configuration (often more than 50Mb will be loaded). After VS finished loading, go back to Tools -&gt; Options -&gt; Debugging -&gt; Symbols and check the \u201cSearch the above locations\u2026\u201d checkbox and hit OK. This will prevent the debugger from connecting to the server when you do not want it.<\/p>\n<p class=\"MsoListParagraphCxSpMiddle\"><span><span>2)<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span>Sometimes you may notice that some variables or methods are not available. The reason for this is that you are using Retail\/Optimized version. One result of the retail optimizations is that certain information is not available or \u201cinlined\u201d. You will still have the source information, but you may not be able to access the data or set breakpoints. For the most part however everything should be normal. <\/p>\n<p class=\"MsoListParagraphCxSpLast\"><span><span>3)<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span>Will this work with VB Express? <br \/>No. This functionality relies on some VisualStudio components that Express versions do not have.<\/p>\n<p class=\"MsoListParagraphCxSpLast\">&nbsp;<\/p>\n<p class=\"MsoNormal\">&#8211; Vladimir, VisualBasic team<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; One of the things we have been working on recently&nbsp;was publishing sources of VisualBasic runtime library. I am very excited to announce that the sources of VB runtime (Microsoft.VisualBasic.dll)&nbsp;are publicly available now!&nbsp;&nbsp;This is a part of a more general work on making .Net Framework sources available to public ( http:\/\/weblogs.asp.net\/scottgu\/archive\/2007\/10\/03\/releasing-the-source-code-for-the-net-framework-libraries.aspx ). The most important [&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":[192,195],"tags":[54,74,117,166,175],"class_list":["post-4773","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-featured","category-visual-basic","tag-debugger","tag-ide","tag-orcas","tag-vb2008","tag-vladimir"],"acf":[],"blog_post_summary":"<p>&nbsp; One of the things we have been working on recently&nbsp;was publishing sources of VisualBasic runtime library. I am very excited to announce that the sources of VB runtime (Microsoft.VisualBasic.dll)&nbsp;are publicly available now!&nbsp;&nbsp;This is a part of a more general work on making .Net Framework sources available to public ( http:\/\/weblogs.asp.net\/scottgu\/archive\/2007\/10\/03\/releasing-the-source-code-for-the-net-framework-libraries.aspx ). The most important [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/4773","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=4773"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/4773\/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=4773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/categories?post=4773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/tags?post=4773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}