<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">greggm's WebLog</title><subtitle type="html" /><id>http://blogs.msdn.com/greggm/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/greggm/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2008-03-17T16:42:00Z</updated><entry><title>Notes from debugging a managed memory leak</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2009/10/29/notes-from-debugging-a-managed-memory-leak.aspx" /><id>http://blogs.msdn.com/greggm/archive/2009/10/29/notes-from-debugging-a-managed-memory-leak.aspx</id><published>2009-10-30T00:49:00Z</published><updated>2009-10-30T00:49:00Z</updated><content type="html">&lt;P&gt;Recently, I spent a while digging into a managed memory leak. This is a pretty well-worn blog topic, but I figured I would add my two cents to it anyway, as I found a few things that I didn't notice in the existing blogs.&lt;/P&gt;
&lt;P&gt;First, Rico wrote up the basic approach back in 2004, so you should start by reading this - &lt;A href="http://blogs.msdn.com/ricom/archive/2004/12/10/279612.aspx" mce_href="http://blogs.msdn.com/ricom/archive/2004/12/10/279612.aspx"&gt;http://blogs.msdn.com/ricom/archive/2004/12/10/279612.aspx&lt;/A&gt;. This will give you an intro to using sos.dll in WinDbg.&lt;/P&gt;
&lt;P&gt;What I would like to add:&lt;/P&gt;
&lt;H3&gt;#1: How to decide if you have a leak in the first place. &lt;/H3&gt;
&lt;P&gt;Since GC's happen non-deterministically, it can be hard to know if you actually have a managed leak. For example, if you look at memory usage at the end of a user scenario, you will likely see memory usage all over the map based on when the last GC happened. The best technique I found for this is to stop after gen-2 collections. This isn't perfect since gen-2 collections can still happen at any time in your code, but it still gives you a better estimate then stopping after user scenarios.&lt;/P&gt;
&lt;P&gt;To stop after the next gen-2 GC: !findroots -gen 2&lt;/P&gt;
&lt;P&gt;Note that this command is new for the CLRv4 version of sos.dll (also available in Silverlight). I am assuming that you could achieve similar functionality with a well-placed breakpoint in older CLRs, but I am not familiar enough with the inner workings of the GC to tell you where.&lt;/P&gt;
&lt;H3&gt;#2: Use CLRProfiler to visualize the leaks&lt;/H3&gt;
&lt;P&gt;This may have been specific to my scenario, but I didn't have a lot of success with !gcroot. I had more success understanding the problem by loading up a .log file in CLRProfiler (&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=a362781c-3870-43be-8926-862b40aa0cd0&amp;amp;DisplayLang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=a362781c-3870-43be-8926-862b40aa0cd0&amp;amp;DisplayLang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=a362781c-3870-43be-8926-862b40aa0cd0&amp;amp;DisplayLang=en&lt;/A&gt;). One note that I found here was to _not_ use '-xml' when saving out the log as CLRProfiler doesn't understand the XML format.&lt;/P&gt;
&lt;P&gt;To save the log out: !TraverseHeap c:\users\greggm\desktop\myheap.log&lt;/P&gt;
&lt;H3&gt;#3: !gcroot doesn't show roots in CCW's&lt;/H3&gt;
&lt;P&gt;When native code calls into managed code from COM, native code gets a CCW (COM callable wrapper). If native code leak's its CCW, the managed object will be leaked, but !gcroot will not tell you why.&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9915051" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry><entry><title>Tracing calls to QueryInterface on a managed object</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2009/07/23/tracing-calls-to-queryinterface-on-a-managed-object.aspx" /><id>http://blogs.msdn.com/greggm/archive/2009/07/23/tracing-calls-to-queryinterface-on-a-managed-object.aspx</id><published>2009-07-24T00:31:00Z</published><updated>2009-07-24T00:31:00Z</updated><content type="html">&lt;P&gt;To date, one difficulty with implementing COM interfaces in managed code is that until now there has been know way to debug into QueryInterface. With CLR v4, its now possible to modify your object to trace calls to QueryInterface using the new ICusomQueryInterface interface (see &lt;A href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.icustomqueryinterface.getinterface(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.icustomqueryinterface.getinterface(VS.100).aspx"&gt;MSDN&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;Example:&lt;BR&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;ComVisible&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;)]&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;sealed&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyObject&lt;/SPAN&gt; : IMyInterface, ICustomQueryInterface&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;CustomQueryInterfaceResult ICustomQueryInterface.GetInterface(&lt;SPAN style="COLOR: blue"&gt;ref&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Guid&lt;/SPAN&gt; iid, &lt;SPAN style="COLOR: blue"&gt;out&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;IntPtr&lt;/SPAN&gt; ppv)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Debugger&lt;/SPAN&gt;.Log(1, &lt;SPAN style="COLOR: #a31515"&gt;"MyObject"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #a31515"&gt;"MyObject: QI'ed for "&lt;/SPAN&gt; + iid.ToString() + &lt;SPAN style="COLOR: #a31515"&gt;"\n"&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ppv = &lt;SPAN style="COLOR: #2b91af"&gt;IntPtr&lt;/SPAN&gt;.Zero;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; CustomQueryInterfaceResult.NotHandled;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;};&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9846815" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry><entry><title>What to do with a machine that doesn't support Hyper-V...</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2009/05/12/what-to-do-with-a-machine-that-doesn-t-support-hyper-v.aspx" /><id>http://blogs.msdn.com/greggm/archive/2009/05/12/what-to-do-with-a-machine-that-doesn-t-support-hyper-v.aspx</id><published>2009-05-12T19:41:00Z</published><updated>2009-05-12T19:41:00Z</updated><content type="html">&lt;P&gt;In my little corner of the world, during the last year (give or take) Hyper-V went from something that a few people were playing with to something that every single person couldn't live without. The huge benefit to us is the 'snapshot' feature, which allows us to instantaneously get a test machine back to clean state.&lt;/P&gt;
&lt;P&gt;This left me with one problem&amp;nbsp;- what to do with my old test machine which was too old to support Hyper-V, but too new to just throw away. Fortunately, Win7 came to my rescue by adding support for booting off a VHD (virtual hard disk). Now I can use &lt;A href="http://technet.microsoft.com/en-us/library/cc720381.aspx" mce_href="http://technet.microsoft.com/en-us/library/cc720381.aspx"&gt;differencing virtual hard disks&lt;/A&gt;, as a poor-man's Hyper-V and still get some millage out of my old test boxes.&lt;/P&gt;
&lt;P&gt;Basic reimaging procedure:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Boot to my physical hard drive&lt;/LI&gt;
&lt;LI&gt;Delete the current differencing disk&lt;/LI&gt;
&lt;LI&gt;Create a new differencing disk&lt;/LI&gt;
&lt;LI&gt;Boot back to my differencing disk&lt;/LI&gt;
&lt;LI&gt;Rejoin the domain and install my test software (Visual Studio in my case)&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Here is how I set this up:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Installed Win7 to my physical hard drive&lt;/LI&gt;
&lt;LI&gt;After that install completed, I created a new Virtual Hard disk from the Disk Management MMC tool (Computer Management-&amp;gt;Storage-&amp;gt;Disk Management). I created a fixed Virtual Hard drive but I actually think that I dynamic disk would have been better since most of the parent virtual hard disk will remain empty. I named this file c:\windows7.vhd.&lt;/LI&gt;
&lt;LI&gt;Boot to the Win7 installer again to install a second partition of Win7 on the VHD&lt;/LI&gt;
&lt;LI&gt;After the installer finishes initializing, go to the repair tools and open a command prompt&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;Run 'diskpart'&lt;/LI&gt;
&lt;LI&gt;select vdisk file=c:\windows7.vhd.&lt;/LI&gt;
&lt;LI&gt;attach vdisk&lt;/LI&gt;
&lt;LI&gt;exit&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;Now continue the Win7 installer, select the virtual disk as the partition to install to. Note that in RC builds, Win7 will warn you that Windows cannot install to this partition, but this warning appears to be ignorable.&lt;/LI&gt;
&lt;LI&gt;After the install completes, install anything else to that parent partition that you need (ex: development tools, baseline libraries, etc).&lt;/LI&gt;
&lt;LI&gt;Boot back to the physical hard drive.&lt;/LI&gt;
&lt;LI&gt;Create a new differing vhd using the 'diskpart' tool (create vdisk file=c:\windows7.diff.vhd parent=c:\windows7.vhd)&lt;/LI&gt;
&lt;LI&gt;Add a new boot menu entry for the differencing vhd, and set it as the default:&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;bcdedit /copy {guid_of_vdisk} /d "Win7 (Diff VHD)" this will create a new boot entry and assign a Guid to it&lt;/LI&gt;
&lt;LI&gt;bcdedit /set {guid_of_copy} device vhd=[C:]\windows7.diff.vhd&lt;/LI&gt;
&lt;LI&gt;bcdedit /set {guid_of_copy} osdevice vhd=[C:]\windows7.diff.vhd&lt;/LI&gt;
&lt;LI&gt;bcdedit /default {guid_of_copy}&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;Boot to your new diff vhd and test away&lt;/LI&gt;&lt;/OL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9607704" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry><entry><title>Disabling script debugging in VS 2008 + IE8</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2009/04/06/disabling-script-debugging-in-vs-2008-ie8.aspx" /><id>http://blogs.msdn.com/greggm/archive/2009/04/06/disabling-script-debugging-in-vs-2008-ie8.aspx</id><published>2009-04-07T03:11:00Z</published><updated>2009-04-07T03:11:00Z</updated><content type="html">&lt;P&gt;Visual Studio 2008 shipped with a feature to automatically enable script debugging when starting IE8 from Visual Studio. In other words, if you are using VS 2008 and IE8, there is no longer a need to tweak IE options to debug your site.&lt;/P&gt;
&lt;P&gt;However, this feature unfortunately created a problem which we didn't notice before VS 2008 shipped - web sites which create a large number of dynamic documents can perform quite poorly under the debugger, and now there is no option to run your site outside the debugger. If you open solution explorer and see the document list under 'Script Documents' dance up and down, you are running into this problem.&lt;/P&gt;
&lt;H3&gt;Work around:&lt;/H3&gt;
&lt;OL&gt;
&lt;LI&gt;This work around requires the Silverlight 2 Tools for Visual Studio 2008 SP1 to be installed. So if you don't have these tools installed, you can download them from Microsoft (&lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=C22D6A7B-546F-4407-8EF6-D60C8EE221ED&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=C22D6A7B-546F-4407-8EF6-D60C8EE221ED&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=C22D6A7B-546F-4407-8EF6-D60C8EE221ED&amp;amp;displaylang=en&lt;/A&gt;). If this is not an option for you, there is some alternative work arounds at the bottom of this blog post.&lt;/LI&gt;
&lt;LI&gt;Right click on your project and open up project properties&lt;/LI&gt;
&lt;LI&gt;Go to the 'Start Options' sheet, and click the 'Silverlight' button at the bottom of the screen. Because the debugger cannot debug both Silverlight code and Script code at the same time, this will disable Script debugging and therefore avoid the problem.&lt;/LI&gt;&lt;/OL&gt;
&lt;H3&gt;Request for feedback:&lt;/H3&gt;
&lt;P&gt;If you want to disable script debugging, I would love to hear about your scenario. We are aware of the performance issues with applications that create many documents. We hope to address this in a future version of Visual Studio.&lt;/P&gt;
&lt;H3&gt;Alternative work around – disable all script debugging:&lt;/H3&gt;
&lt;UL&gt;
&lt;LI&gt;Open a new command prompt (start-&amp;gt;run, cmd.exe). If you are on a 64-bit computer this needs to be a 32-bit prompt (start-&amp;gt;run, c:\windows\syswow64\cmd.exe)&lt;/LI&gt;
&lt;LI&gt;reg add HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\AD7Metrics\Engine\{F200A7E7-DEA5-11D0-B854-00A0244A1DE2} /v ProgramProvider /d {4FF9DEF4-8922-4D02-9379-3FFA64D1D639} /f&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;If you are using Visual Web Developer Express, replace 'VisualStudio' with 'VWDExpress':&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;reg add HKLM\SOFTWARE\Microsoft\VWDExpress\9.0\AD7Metrics\Engine\{F200A7E7-DEA5-11D0-B854-00A0244A1DE2} /v ProgramProvider /d {4FF9DEF4-8922-4D02-9379-3FFA64D1D639} /f&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;If you want to restore your computer so that you can debug scripts again:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;reg add HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\AD7Metrics\Engine\{F200A7E7-DEA5-11D0-B854-00A0244A1DE2} /v ProgramProvider /d {170EC3FC-4E80-40AB-A85A-55900C7C70DE} /f&lt;/LI&gt;&lt;/UL&gt;
&lt;H3&gt;Work around for performance problems caused by 'anonymous code' nodes:&lt;/H3&gt;
&lt;P&gt;Some sites run into problems being debugged due to numerous "anonymous code" nodes in solution explorer. For these sites, instead of disabling script debugging completely, it's possible to disable just the 'anonymous code' nodes. This requires Visual Studio 2008 SP1. To do so:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;reg add HKCU\Software\Microsoft\VisualStudio\9.0\Debugger /v HideAnonymousScriptCodeNodes /t REG_DWORD /d 1 /f&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9534792" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry><entry><title>Script debugging broken in VS 2005 after installing IE8</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2009/04/01/script-debugging-broken-in-vs-2005-after-installing-ie8.aspx" /><id>http://blogs.msdn.com/greggm/archive/2009/04/01/script-debugging-broken-in-vs-2005-after-installing-ie8.aspx</id><published>2009-04-01T20:16:00Z</published><updated>2009-04-01T20:16:00Z</updated><content type="html">&lt;P&gt;&lt;EM&gt;[Note: This post has been updated&amp;nbsp;with new information]&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;There is currently an issue in VS 2005 after you install IE8 where script debugging is broken. If you are using VS 2008, this will not be a problem.&lt;/P&gt;
&lt;P&gt;Brad Sullivan posted the work around in the debugger &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/e2c795cd-b7a0-4fad-b7c9-b1ca40d7302e/" mce_href="http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/e2c795cd-b7a0-4fad-b7c9-b1ca40d7302e/"&gt;forum&lt;/A&gt;. Here is what he said:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;IE 8 has a feature called Loosely-Coupled Internet Explorer (LCIE) which results in IE running across multiple processes. &lt;BR&gt;&lt;A href="http://www.microsoft.com/windows/internet-explorer/beta/readiness/developers-existing.aspx#lcie"&gt;http://www.microsoft.com/windows/internet-explorer/beta/readiness/developers-existing.aspx#lcie&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Older versions of the Visual Studio Debugger get confused by this and cannot figure out how to attach to the correct process.&amp;nbsp; You can work around this by disabling the process growth feature of LCIE.&amp;nbsp; Here's how:&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp; Open RegEdit&lt;BR&gt;2)&amp;nbsp; Browse to HKEY_LOCALMACHINE -&amp;gt; SOFTWARE -&amp;gt; Microsoft -&amp;gt; Internet Explorer -&amp;gt; Main&lt;BR&gt;3)&amp;nbsp; Add a dword under this key called TabProcGrowth&lt;BR&gt;4)&amp;nbsp; Set TabProcGrowth to 0&lt;/P&gt;
&lt;P&gt;Note that If you are using a 64-bit computer, you want to edit the 32-bit registry.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In addition to this,&amp;nbsp;IE's installer will re-disable script debugging. So you will need to reenable it:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Open Internet Explorer &lt;/LI&gt;
&lt;LI&gt;Go to Tools-&amp;gt;Internet Options&lt;/LI&gt;
&lt;LI&gt;Switch to the Advanced tab&lt;/LI&gt;
&lt;LI&gt;Uncheck 'Disable script debugging (internet explorer)'&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;One finial note&amp;nbsp;- if you are attempting to debug a browser extension or ActiveX control written in native or managed code, you may experience the same problem. This will happen on all OSs with VS 2005, and on XP/Server 2003 with VS 2008. In this situation, you need to follow Brad’s work around.&lt;BR&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;[July 10th Update]&lt;/STRONG&gt;: We recently discovered another issue with Script Debugging after installing IE8. The issue does not always repro, which is how we missed it, but there is a workaround. To work around:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Install Visual Web Developer 2008 Express Edition, which is a free download from &lt;A href="http://www.microsoft.com/express/vwd/Default.aspx"&gt;http://www.microsoft.com/express/vwd/Default.aspx&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;Optional step: Uninstall Visual Web Developer express&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;This will update the Visual Studio shared script debugging files (the files shared between every version of Visual Studio to enable script debugging) from the Visual Studio 2005 version to the 2008 version, and will thus work around the issue.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9527342" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry><entry><title>Exceptions Dialog explained (or what does 'User-Unhandled' mean)</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2008/12/31/exceptions-dialog-explained-or-what-does-user-unhandled-mean.aspx" /><id>http://blogs.msdn.com/greggm/archive/2008/12/31/exceptions-dialog-explained-or-what-does-user-unhandled-mean.aspx</id><published>2008-12-31T21:38:00Z</published><updated>2008-12-31T21:38:00Z</updated><content type="html">&lt;P&gt;We recently had some questions on our internal Visual Studio Debugger forum about the exceptions dialog. So I decided to take a stab at explaining it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG title="Exceptions dialog" style="WIDTH: 725px; HEIGHT: 360px" height=360 alt="Exceptions dialog" src="http://www.danfernandez.com/view/view.aspx?ID=193" width=725 mce_src="http://www.danfernandez.com/view/view.aspx?ID=193"&gt;&lt;/P&gt;&lt;BR&gt;
&lt;H3&gt;Just My Code&lt;/H3&gt;
&lt;P&gt;The first step to understanding this dialog is to understand a feature called 'Just My Code' (enabled/disabled with 'Tools-&amp;gt;Options-&amp;gt;Debugging-&amp;gt;Enable Just My Code'). Just My Code is currently a managed-only debugging feature. When enabled, the debugger divides up all the code running in the debugged process into two groups&amp;nbsp;- your code, and non-user code (system code). It then tries to hide the details of system code from you so that you can concentrate on looking at your own code.&lt;/P&gt;
&lt;H3&gt;User-Unhandled Defined&lt;/H3&gt;
&lt;P&gt;Next concept to explain: 'User-Unhandled' exceptions. An exception becomes 'User-Unhandled' after:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;An exception travels through your code&amp;nbsp; (your code either throws the exception or calls into system code which throws an exception back to you)&lt;BR&gt;-and-&lt;/LI&gt;
&lt;LI&gt;Your code doesn't catch the exception&lt;BR&gt;-and-&lt;/LI&gt;
&lt;LI&gt;The exception is caught by system code&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;In other words: 'User-unhandled' does not necessarily mean that your app is actually crashing. The debugger is trying to tell you about an exception which is probably interesting before this exception is swallowed up by the system. After catching the exception, the system might fall over and die, or it might be totally expected (in which case you should go to Debug-&amp;gt;Exceptions and turn off stopping on 'User Unhandled' exceptions for your app).&lt;/P&gt;
&lt;P&gt;Example: You are building a WinForms app which has a bug in its handler for some button which will cause it to deref null. If you run this app outside of a debugger, and then attach the debugger, WinForms will quietly swallow the exception. But if you have 'User unhandled' exceptions enabled, the debugger will stop and you can easily find out what went wrong.&lt;/P&gt;
&lt;H3&gt;Now to the dialog&lt;/H3&gt;
&lt;P&gt;Now that we have the concepts, let's explain how they are expressed in the dialog.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;For exceptions that don't support Just My Code&lt;/STRONG&gt; (C++ Exceptions, Managed Debug Assistants, Win32 Exceptions, Common Language Runtime Exceptions if Just My Code is disabled) – the debugger will show the 'User-Unhandled' checkbox as checked and disabled. What this is trying to tell you is that this setting is 'N/A'. For this type of code, the debugger doesn't divide the world up into user code and non-user code. So an exception could never go user-unhandled.&lt;/P&gt;
&lt;P&gt;For these exceptions, the 'Thrown' column has the same meaning that it does in other debuggers (WinDbg calls this 'first chance', VS 2002/3 referred to this as 'Break' instead of 'Continue').&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;For exceptions Common Language Runtime Exceptions&lt;/STRONG&gt; (with Just My Code enabled): Both the 'Thrown' and 'User-Unhandled' column can be checked. 'User-unhandled' has the meaning discussed above. Checking 'Thrown' will cause the debugger to stop when either user code throws the exception, or when system code throws the exception back to user code. In other words, the debugger will not stop for internal exceptions within the system code.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;What about unhandled exceptions? &lt;/STRONG&gt;The debugger always stops on unhandled exceptions since the process will otherwise exit. Since the debugger always stops, there doesn't need to be a checkbox for this one.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9258789" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry><entry><title>Attaching a debugger at startup</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2008/09/12/attaching-a-debugger-at-startup.aspx" /><link rel="enclosure" type="text/plain" length="3255" href="http://blogs.msdn.com/greggm/attachment/8948027.ashx" /><id>http://blogs.msdn.com/greggm/archive/2008/09/12/attaching-a-debugger-at-startup.aspx</id><published>2008-09-12T22:30:00Z</published><updated>2008-09-12T22:30:00Z</updated><content type="html">&lt;P&gt;Sometimes you need to debug a process, and you need to attach the debugger right away, but you cannot launch the process under the debugger. For example, if the process you need to debug is a Windows Service, the Windows Service Manager must launch the process. How can you debug it?&lt;/P&gt;
&lt;P&gt;Here are the two easiest solutions:&lt;/P&gt;
&lt;P&gt;#1: Windows includes registry settings under the ‘Image File Execution Options’ key that can help you debug this. I blogged about this before back in February of 2005 (&lt;A href="http://blogs.msdn.com/greggm/archive/2005/02/21/377663.aspx" mce_href="http://blogs.msdn.com/greggm/archive/2005/02/21/377663.aspx"&gt;http://blogs.msdn.com/greggm/archive/2005/02/21/377663.aspx&lt;/A&gt;). Most of the information is that blog is still correct. A few updates worth mentioning though:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Visual Studio 2008 can support session 0 processes on Vista or Server 2008.&lt;/LI&gt;
&lt;LI&gt;Visual Studio 2008 can support 64-bit operating systems. The only remaining 64-bit restriction is that 64-bit managed processes cannot be debugged this way since the .NET Framework does not support managed+native debugging of 64-bit processes.&lt;/LI&gt;
&lt;LI&gt;Visual Studio 2005 does not support this feature on Windows Vista or Server 2008. You will need to upgrade to 2008 for these operating systems.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;BR&gt;#2: You can add code to your app to cause it to pause waiting for a debugger to attach. I am attaching an example header file for making this work. We ship several executables that embed similar code for this reason. Just call ‘RuntimeDiagnostics::CheckPauseOnStartupOption()’ as the first line of code in your main routine. You can do something verify similar for managed code as well. Just call ‘System.Diagnostics.Debugger.IsAttached’ instead of IsDebuggerPresent.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;int&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; _tmain(&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; argc, _TCHAR* argv[])&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;RuntimeDiagnostics::CheckPauseOnStartupOption();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Then set this registy key if you need your app to pause:&lt;/P&gt;&lt;FONT face="Courier New"&gt;
&lt;P&gt;Windows Registry Editor Version 5.00&lt;/P&gt;
&lt;P&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sample.exe]&lt;BR&gt;"PauseOnStartup"=dword:00000001&lt;/P&gt;&lt;/FONT&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8948027" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry><entry><title>Writing a script debugger without using the MDM</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2008/06/09/writing-a-script-debugger-without-using-the-mdm.aspx" /><link rel="enclosure" type="text/plain" length="10634" href="http://blogs.msdn.com/greggm/attachment/8586872.ashx" /><id>http://blogs.msdn.com/greggm/archive/2008/06/09/writing-a-script-debugger-without-using-the-mdm.aspx</id><published>2008-06-09T21:21:00Z</published><updated>2008-06-09T21:21:00Z</updated><content type="html">&lt;P&gt;Today’s blog is about writing your own script debugger.&lt;/P&gt;
&lt;P&gt;Visual Studio has provided ‘Script’ debugging for a long time. In this context, ‘Script’ refers to script run by jscript.dll or vbscript.dll such as the script code in Internet Explorer, classic ASP scripting, or the cscript/wscript programs. Long long ago, someone provided a sample for creating your own script debugging utilizing the active script debugging interfaces (ex: &lt;A class="" href="http://msdn.microsoft.com/en-us/library/7173hc80(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/7173hc80(VS.85).aspx"&gt;IRemoteDebugApplication&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;However, this sample relied on a Microsoft executable called mdm.exe (IMachineDebugManager/CLSID_MachineDebugManager). After Visual Studio 2003, Visual Studio stopped shipping mdm.exe. So today, I wanted to provide a brief summary of how one could port an mdm.exe-based script debugger to the newer interfaces. Mdm.exe provided essentially two related features&amp;nbsp;-- it allowed a debugger determine what script applications where currently running, and there was an eventing interface that let a debugger be informed when a new script application started. These features worked because the debugger component inside of the target process (pdm.dll) would connect to mdm.exe whenever a new script application was created.&lt;/P&gt;
&lt;P&gt;Today, these features have been moved to&amp;nbsp;pdm.dll. So now, pdm.dll is loaded in both the debugger and in the target process. In the target process pdm.dll still continues to do the same work as it has always done. However, now one can also load pdm.dll into the debugger process to obtain the old MDM features.&lt;/P&gt;
&lt;P&gt;PDM now has a new CLSID for the work that it does in the debugger process – CLSID_MsProgramProvider. It exposes an AD7 interface for obtaining this information: &lt;A class="" href="http://msdn.microsoft.com/en-us/library/bb161298.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb161298.aspx"&gt;IDebugProgramProvider2&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;There is sample code attached to this blog which demonstrates how to launch or attach to a program using these new interfaces.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8586872" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry><entry><title>Reporting a Visual Studio crash to Microsoft</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2008/05/22/reporting-a-visual-studio-crash-to-microsoft.aspx" /><id>http://blogs.msdn.com/greggm/archive/2008/05/22/reporting-a-visual-studio-crash-to-microsoft.aspx</id><published>2008-05-22T21:47:00Z</published><updated>2008-05-22T21:47:00Z</updated><content type="html">&lt;H2&gt;Background&lt;/H2&gt;
&lt;P&gt;Sometimes Visual Studio crashes. It would be nice if this wasn’t the case, but unfortunately it happens. However, like many Microsoft applications, Visual Studio has Error Reporting so that when a problem happens, you can tell us about it in one click. However, sometimes you would like to actually tell a live human about your crash. There are a number of advantages to doing so:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;A human might be able to tell you about a work around that Windows Error reporting doesn’t know about.&lt;/LI&gt;
&lt;LI&gt;A human can tell you if this crash was something that we could diagnose.&lt;/LI&gt;
&lt;LI&gt;It helps to make sure your issue is really fixed. When a developer at Microsoft looks at a Windows Error report, all we see is where the crash happened and some local variables. Sometimes we can figure out what was happening and create a repro to confirm our fix. This is the best case, but it often doesn’t happen this way. More often we need to either guess what a fix is but not test the fix, or we are unable to even guess what a correct fix might be.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;For these reasons you might want to also report the issue through the Visual Studio product feedback center.&lt;BR&gt;&lt;/P&gt;
&lt;H2&gt;What to do&lt;/H2&gt;
&lt;P&gt;Step #1: Go to &lt;A href="http://connect.microsoft.com/site/sitehome.aspx?SiteID=210" mce_href="http://connect.microsoft.com/site/sitehome.aspx?SiteID=210"&gt;http://connect.microsoft.com/site/sitehome.aspx?SiteID=210&lt;/A&gt; and enter a bug.&lt;/P&gt;
&lt;P&gt;Step #2: In the bug, include the ‘bucketing information’. You can find this information by:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Open the event viewer (Right click on Computer and go to ‘Manage’; click on the ‘Event Viewer’ tree item).&lt;/LI&gt;
&lt;LI&gt;Open the ‘Application’ section&lt;/LI&gt;
&lt;LI&gt;Look for the entry that happened about the correct time and had the source set to ‘Application Error’&lt;/LI&gt;
&lt;LI&gt;Copy the content and paste it into the bug, it should look something like:&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Faulting application devenv.exe, version 9.0.30428.1, time stamp 0x4815597f, faulting module scriptle2.dll, version 9.0.21022.8, time stamp 0x47317e18, exception code 0xc0000005, fault offset 0x0000328c, process id 0xfbc, application start time 0x01c8bc39887cac69.&lt;BR&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8533192" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry><entry><title>Visual Studio 2008 SP1 Beta</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2008/05/16/visual-studio-2008-sp1-beta.aspx" /><id>http://blogs.msdn.com/greggm/archive/2008/05/16/visual-studio-2008-sp1-beta.aspx</id><published>2008-05-17T03:09:00Z</published><updated>2008-05-17T03:09:00Z</updated><content type="html">&lt;P&gt;In case you missed it, Visual Studio 2008 SP1 Beta has been released:&lt;BR&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=CF99C752-1391-4BC3-BABC-86BC0B9E8E5A&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=CF99C752-1391-4BC3-BABC-86BC0B9E8E5A&amp;amp;displaylang=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;For the debugger, Visual Studio 2008 SP1 contains:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;As with all service packs, fixes for all the significant bugs that we found since Visual Studio 2008 RTM.&lt;/LI&gt;
&lt;LI&gt;Improved support for downloading symbols and PDBs for the .NET Framework and other Microsoft products.&lt;/LI&gt;
&lt;LI&gt;Improvements for using Visual Studio with non-local symbol stores (such as the Microsoft public symbol servers)&lt;/LI&gt;
&lt;LI&gt;Step into specific for managed. We have had this feature with native for years, with SP1 we added this support for managed as well. If a line contains multiple function calls, you can right click on the line in the editor and select which function you would like to step into.&lt;/LI&gt;
&lt;LI&gt;Step filtering for managed. There is now an option to stop stepping into property get routines.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;We want to try and get the RTM version into customer’s hands as soon as we can, so this means there isn’t too long for us to act on customer feedback. So if you are interested, give it a whirl soon.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;One very important note&lt;/STRONG&gt;: If you have installed any Visual Studio 2008 hot fix, make sure that you run this tool _before_ installing Visual Studio 2008 SP1 Beta:&lt;BR&gt;&lt;A href="http://code.msdn.microsoft.com/RemoveKB944899"&gt;http://code.msdn.microsoft.com/RemoveKB944899&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If you would rather not run a tool, manual steps can be found here:&lt;BR&gt;&lt;A href="http://blogs.msdn.com/heaths/archive/2008/05/16/kb944899-should-be-removed-before-installing-visual-studio-2008-sp1.aspx"&gt;http://blogs.msdn.com/heaths/archive/2008/05/16/kb944899-should-be-removed-before-installing-visual-studio-2008-sp1.aspx&lt;/A&gt;&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8515853" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry><entry><title>Visual Studio Remote Debugger Service user account requirements</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2008/05/15/visual-studio-remote-debugger-service-user-account-requirements.aspx" /><id>http://blogs.msdn.com/greggm/archive/2008/05/15/visual-studio-remote-debugger-service-user-account-requirements.aspx</id><published>2008-05-15T23:18:00Z</published><updated>2008-05-15T23:18:00Z</updated><content type="html">&lt;P&gt;I was asked today -- Why does the Visual Studio Remote Debugger Service need to be run as an administrator?&lt;/P&gt;
&lt;P&gt;Since it doesn't appear that this information is documented, I figured I would provide an answer. Running the remote debugger service as an administrator is really a recommendation rather than a requirement. The actual requirement is:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Account must have the 'logon as service' privilege&lt;/LI&gt;
&lt;LI&gt;Account must be able to connect 'backwards' to the Visual Studio computer over the network. For this reason, on a domain, its easiest if the service is running under Local System, Network Service, or a domain account.&amp;nbsp; If you want to run it as a local account see: &lt;A href="http://blogs.msdn.com/greggm/archive/2004/10/04/237519.aspx"&gt;http://blogs.msdn.com/greggm/archive/2004/10/04/237519.aspx&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Account must have rights to debug the target process. This means the service needs to either run under the same account as the process to be debugged, or the service needs to run as an administrator.&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;We recommend running the service as an administrator because:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The service only allows connections from administrators, so there is no security reason why running it as an administrator is bad.&lt;/LI&gt;
&lt;LI&gt;Running it without administrative privileges may put the user in a situation where the Visual Studio user has access to debug a particular process, but since the remote debugging service lacks these rights the Visual Studio user is not allowed to debug the process.&lt;/LI&gt;
&lt;LI&gt;It’s a&amp;nbsp; lot easier to setup this way, and there is enough that can go wrong with remote debugging already.&lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8509180" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry><entry><title>Exception Filter Inject</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2008/04/21/exception-filter-inject.aspx" /><id>http://blogs.msdn.com/greggm/archive/2008/04/21/exception-filter-inject.aspx</id><published>2008-04-21T22:14:00Z</published><updated>2008-04-21T22:14:00Z</updated><content type="html">&lt;P&gt;Recently I have found the need to have an exception filter in some C# code that I have written. Since there is no language support for this, I wrote an IL instrumentation tool:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://code.msdn.microsoft.com/ExceptionFilterInjct"&gt;http://code.msdn.microsoft.com/ExceptionFilterInjct&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;For debugging scenarios, the value of this tool is to make it easier to save a minidump of exceptions. Unfortunately, there is not yet a rich Visual Studio experience for managed minidumps, so you will need to use sos.dll (see &lt;A href="http://msdn2.microsoft.com/en-us/magazine/cc164138.aspx"&gt;http://msdn2.microsoft.com/en-us/magazine/cc164138.aspx&lt;/A&gt;).&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8415206" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry><entry><title>Advice on creating a code generator</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2008/03/28/advice-on-creating-a-code-generator.aspx" /><id>http://blogs.msdn.com/greggm/archive/2008/03/28/advice-on-creating-a-code-generator.aspx</id><published>2008-03-28T21:07:00Z</published><updated>2008-03-28T21:07:00Z</updated><content type="html">&lt;P&gt;I have been spending some time recently creating a custom code generator that outputs C++ and C# code from a custom XML format. This blog is about some of what I have learned while working on this.&lt;/P&gt;
&lt;H3&gt;Advice #1: Use '#line'&lt;/H3&gt;
&lt;P&gt;There is a really cheap way to get a debugging experience for your custom language: #line. With #line, you get to change the debug info that ilasm/csc/vbc/cl writes into the PDB so that the debug info points back to the original source file instead of the one that your code generator creates. This is quite handy if you custom language has at least parts where there is a strong connection between the generated code and the custom language. Notes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;There is not a similar technique to allow you to re-associate variables, so I would advise using the original names of variables if possible.&lt;/LI&gt;
&lt;LI&gt;If a line of the original source expands to multiple lines of the generated code, just repeat the #line before each line of the generated code.&lt;/LI&gt;
&lt;LI&gt;There is an issue with this technique if your source language is XML-based in VS 2008 RTM. Visual Studio hopes to correct this problem in SP1.&lt;/LI&gt;
&lt;LI&gt;In C#, you can use this technique with #pragma checksum to set the checksum of the source file. This is useful if you expect to have a bunch of source files with the same name (ex: default.aspx) or if you are already grabbing the checksum for some other reason. Otherwise, it is probably overkill for a custom code generator. Note that the GUID with #pragma checksum identifies the hash algorithm (ex: MD5 is { 406ea660-64cf-4c82-b6f0-42d48172a799}).&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;Generated file:&lt;BR&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Main(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;[] args)&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;#line&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; 1 "HelloWorld.ExampleLanguage"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Hello World"&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;#line&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; default&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;HelloWorld.ExampleLanguage (custom language source file):&lt;BR&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Hello World&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;Advise #2: Use XML&lt;/H3&gt;
&lt;P&gt;XML is a great way to do a custom language these days because at no cost, you get a lexer, a parser, syntax validation, a language sevice, and your compiler gets to work with deserialized classes instead of with text. Here is the procedure that I would recommend:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Figure out what you would like your language to look like by writing a bunch of examples.&lt;/LI&gt;
&lt;LI&gt;Run xsd.exe over your examples to create the start of a schema.&lt;/LI&gt;
&lt;LI&gt;Open up the generated schema and start making changes. You might need to make changes because the generated schema wasn’t specific enough (ex: you have an enumerator that it has represented as a string), or because your examples had bugs in it, or because you want to add documentation.&lt;/LI&gt;
&lt;LI&gt;Once you have the schema vaguely correct, it is time to use xsd.exe to create class files from your schema. This allows you to use XmlSerializer.Deserialize to create classes from the input XML with little work. You want to create a build step to do this as you will be changing your schema often.&lt;/LI&gt;
&lt;LI&gt;Hookup the schema file so that you can run it as part of compilation. This provides you with a pretty good set of validation without effort. I did this by embedding the schema as a resource in my compiler, but obviously you could also leave it as a file that your compiler opens.&lt;/LI&gt;
&lt;LI&gt;(Optional) Use sgen.exe to generate the serialization assembly --&amp;nbsp;XmlSerializer depends on a generated assembly to perform the serialization/deserialization. By default, this assembly is generated dynamically, but you can also use sgen.exe to generate this assembly up front.&lt;/LI&gt;
&lt;LI&gt;When you edit your language, edit in Visual Studio and make sure that the XML editor has your schema open. The XML editor will pick up schema items that are in your project, and it will also pick up schemas that are in the Visual Studio 'schema directory'.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Example target for running xsd.exe:&amp;nbsp;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;!--&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Generate Example.cs using xsd.exe &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;--&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Target&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;GenerateXSDClasses&lt;/SPAN&gt;"&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Inputs&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;Example.xsd&lt;/SPAN&gt;"&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Outputs&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;$(IntermediateOutputPath)\Example.cs&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Exec&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Command&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;$(RunManagedToolPath) xsd.exe Example.xsd /classes /fields /namespace:ExampleCompiler /out:$(IntermediateOutputPath)&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;&lt;BR&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Target&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;ItemGroup&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Compile&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Include&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;$(IntermediateOutputPath)\Example.cs&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;ItemGroup&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;You would also need to wire the target into a property group that runs before compiling&lt;/P&gt;
&lt;P&gt;Example of embedding the schema as a resource:&lt;BR&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;EmbeddedResource&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Include&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;Example.xsd&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Example of using the schema:&lt;BR&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; InitializeSchema()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (s_schemaSet != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;throw&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;InvalidOperationException&lt;/SPAN&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;System.Reflection.&lt;SPAN style="COLOR: #2b91af"&gt;Assembly&lt;/SPAN&gt; ThisAssembly = &lt;SPAN style="COLOR: blue"&gt;typeof&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;&lt;EM&gt;MyType&lt;/EM&gt;&lt;/SPAN&gt;).Assembly;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Stream&lt;/SPAN&gt; stream = ThisAssembly.GetManifestResourceStream(&lt;SPAN style="COLOR: #a31515"&gt;"ExampleCompiler.Example.xsd"&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;XmlReader&lt;/SPAN&gt; schemaDocument = &lt;SPAN style="COLOR: #2b91af"&gt;XmlReader&lt;/SPAN&gt;.Create(stream);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;s_schemaSet = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; System.Xml.Schema.&lt;SPAN style="COLOR: #2b91af"&gt;XmlSchemaSet&lt;/SPAN&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;s_schemaSet.Add(&lt;SPAN style="COLOR: #a31515"&gt;"http://schemas.microsoft.com/vstudio/Example/2008"&lt;/SPAN&gt;, schemaDocument);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;s_schemaSet.Compile();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;XmlReaderSettings&lt;/SPAN&gt; settings = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;XmlReaderSettings&lt;/SPAN&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;settings.ConformanceLevel = &lt;SPAN style="COLOR: #2b91af"&gt;ConformanceLevel&lt;/SPAN&gt;.Document;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;settings.Schemas = s_schemaSet;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;settings.ValidationEventHandler += &lt;EM&gt;MyValidationEventHandler&lt;/EM&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;settings.ValidationType = &lt;SPAN style="COLOR: #2b91af"&gt;ValidationType&lt;/SPAN&gt;.Schema;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;XmlReader&lt;/SPAN&gt; reader = &lt;SPAN style="COLOR: #2b91af"&gt;XmlReader&lt;/SPAN&gt;.Create(filename, settings))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;Advise #3: Check in the custom compiler output&lt;/H3&gt;
&lt;P&gt;If you are writing a very high quality compiler that you are trying to productize then, when people use your compiler, you would have them wire it into their build process such that they would input your custom language and get back a dll or exe.&lt;BR&gt;But this is not necessarily the correct bar for a custom code generator. In my case, I am creating a truly custom compiler. Very few people are going to author the input language, and it doesn’t make sense to expend valuable QA resources directly testing the compiler (rather they would test the generated code). So rather than taking the output of my compiler and directly building these files, I instead checkin the compiler output as a baseline, and the build process runs the custom compiler and compares the output to the baseline. If they differ, it issues a build error.&lt;/P&gt;
&lt;P&gt;There are a number of valuable properties that I get out of this 'baseline' approach:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;If I edit the compiler, testing the compiler becomes very simple. I just do a build and see if I got the same result that I expected.&lt;/LI&gt;
&lt;LI&gt;If I edit the input, I get confirmation that the compiler did what I expected. I need to diff the baseline output against the new output and validate that I got expected changes.&lt;/LI&gt;
&lt;LI&gt;Compiler bugs turn into build breaks. If I had a bug in my custom compiler where the output was incorrect, rather than going silently unnoticed instead the bug turns into a build break.&lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8342180" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry><entry><title>Automatically reading source files from TFS</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2008/03/19/automatically-reading-source-files-from-tfs.aspx" /><id>http://blogs.msdn.com/greggm/archive/2008/03/19/automatically-reading-source-files-from-tfs.aspx</id><published>2008-03-20T01:53:00Z</published><updated>2008-03-20T01:53:00Z</updated><content type="html">&lt;P&gt;I recently stumbled upon&amp;nbsp; a blog that explained how to use the Source Server technology to enable the debugger to automatically download source files from TFS. This is useful when you work on a software project that is large enough that you debug against modules that are built by your build lab instead of being built locally.&lt;/P&gt;
&lt;P&gt;Here are instructions for setting up Team Build: &lt;A href="http://jelle.druyts.net/2007/12/09/SettingUpSourceServerForTFSBuilds.aspx"&gt;http://jelle.druyts.net/2007/12/09/SettingUpSourceServerForTFSBuilds.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;After doing this, you will also need to configure the debugger. John Robins has instructions for doing that in &lt;A class="" href="http://msdn.microsoft.com/msdnmag/issues/06/08/UseTheSource/default.aspx" mce_href="http://msdn.microsoft.com/msdnmag/issues/06/08/UseTheSource/default.aspx"&gt;MSDN Magazine&lt;/A&gt;. Go down to the 'Debugging in Visual Studio 2005' section.&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8326488" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry><entry><title>The debugger team is expanding</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/greggm/archive/2008/03/17/the-debugger-team-is-expanding.aspx" /><id>http://blogs.msdn.com/greggm/archive/2008/03/17/the-debugger-team-is-expanding.aspx</id><published>2008-03-18T02:42:00Z</published><updated>2008-03-18T02:42:00Z</updated><content type="html">&lt;P&gt;The Visual Studio Debugger team is expanding, and is looking for candidates. If you are interested in applying for a position,&amp;nbsp;we have openings in &lt;A href="http://members.microsoft.com/careers/search/details.aspx?JobID=3C87062A-3C66-406F-AE23-5E63FE606995&amp;amp;start=1&amp;amp;interval=10&amp;amp;SortCol=DatePosted" mce_href="http://members.microsoft.com/careers/search/details.aspx?JobID=3C87062A-3C66-406F-AE23-5E63FE606995&amp;amp;start=1&amp;amp;interval=10&amp;amp;SortCol=DatePosted"&gt;Dev&lt;/A&gt;, &lt;A href="http://members.microsoft.com/careers/search/details.aspx?JobID=D488A777-1E8B-47BC-93B6-310CD02CFCBB" mce_href="http://members.microsoft.com/careers/search/details.aspx?JobID=D488A777-1E8B-47BC-93B6-310CD02CFCBB"&gt;Test&lt;/A&gt; and &lt;A href="http://members.microsoft.com/careers/search/details.aspx?JobID=C42975A6-AC22-4AAE-93E7-BA677E5AD3BD" mce_href="http://members.microsoft.com/careers/search/details.aspx?JobID=C42975A6-AC22-4AAE-93E7-BA677E5AD3BD"&gt;PM&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;/SPAN&gt;Some great things about working on the debugger:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You are helping to improve a tool which millions of developers use every day. There are few software development tools which impact more people.&lt;/LI&gt;
&lt;LI&gt;You get to use what you sell. There aren’t too many places where you can work on software that you also get to use. But you will have this experience on the debugger team.&lt;/LI&gt;
&lt;LI&gt;You get to play with lots of cool technology. People are always inventing new platforms, and they are always going to need debugged.&lt;/LI&gt;
&lt;LI&gt;Great team&amp;nbsp;-- you will get to work with a team of talented and fun people. You will also get to work with me :)&lt;BR&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8298456" width="1" height="1"&gt;</content><author><name>greggm</name><uri>http://blogs.msdn.com/members/greggm.aspx</uri></author></entry></feed>