<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>apocryph.org &#187; visual studio</title>
	<atom:link href="http://apocryph.org/tag/visual-studio/feed/" rel="self" type="application/rss+xml" />
	<link>http://apocryph.org</link>
	<description>Notes to my future self</description>
	<lastBuildDate>Mon, 09 Aug 2010 16:59:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>.NET framework source code?  Really!?</title>
		<link>http://apocryph.org/2007/10/03/net_framework_source_code_really/</link>
		<comments>http://apocryph.org/2007/10/03/net_framework_source_code_really/#comments</comments>
		<pubDate>Wed, 03 Oct 2007 19:43:43 +0000</pubDate>
		<dc:creator>anelson</dc:creator>
				<category><![CDATA[Migrated from Drupal]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[tech diary]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://apocryph.org/?p=483</guid>
		<description><![CDATA[I just read Scott Guthrie&#8217;s announcement that, starting with Visual Studio 2008, the full, commented source code to the major assemblies in the .NET framework will be available for debugging and analysis, both as a source tarball and on-demand via the public symbol server. I can&#8217;t tell you how many times I&#8217;ve been using a [...]]]></description>
			<content:encoded><![CDATA[<p>I just read <a href="http://weblogs.asp.net/scottgu/archive/2007/10/03/releasing-the-source-code-for-the-net-framework-libraries.aspx">Scott Guthrie&#8217;s announcement</a> that, starting with Visual Studio 2008, the full, commented source code to the major assemblies in the .NET framework will be available for debugging and analysis, both as a source tarball and on-demand via the public symbol server.</p>
<p>I can&#8217;t tell you how many times I&#8217;ve been using a System assembly which is misbehaving, and been forced to use Lutz Roeder&#8217;s Reflector tool to reverse-engineer to uncommented C# code in the hopes of figuring out that is wrong.  It was equivalent to the days of old when the C Runtime Library source code wasn&#8217;t shipped with the compiler.</p>
<p>All I can say is, &#8220;what took so long!?&#8221;</p>
<p><strong>UPDATE</strong> I&#8217;ve read some bitching about the nature of the license under which this code is to be released; specifically, some Microsoft license which is no-modify and no-distribute.  Those who find this unacceptable are, imho, missing the point.  80% of the value of a unrestricted GPL-type .NET Framework source release would be easier diagnosis and debugging anyway, since even if you could fork the MS framework, that would be like modifying the MFC code that shipped with VC 4 and shipping the modified DLLs with your product; you could do it, but you&#8217;d have to be a fucking moron.</p>
]]></content:encoded>
			<wfw:commentRss>http://apocryph.org/2007/10/03/net_framework_source_code_really/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Incredibly annoying gotcha building vshadow sample with Visual Studio 2005</title>
		<link>http://apocryph.org/2007/09/04/incredibly_annoying_gotcha_building_vshadow_sample_visual_studio_2005/</link>
		<comments>http://apocryph.org/2007/09/04/incredibly_annoying_gotcha_building_vshadow_sample_visual_studio_2005/#comments</comments>
		<pubDate>Tue, 04 Sep 2007 23:01:40 +0000</pubDate>
		<dc:creator>anelson</dc:creator>
				<category><![CDATA[Migrated from Drupal]]></category>
		<category><![CDATA[tech diary]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[vshadow]]></category>
		<category><![CDATA[vss]]></category>

		<guid isPermaLink="false">http://apocryph.org/?p=469</guid>
		<description><![CDATA[Today I&#8217;m trying to track down an elusive bug that only presents at a single customer site. We&#8217;ve narrowed it to something having to do with VSS, so now I need to force some VSS snapshots outside of our product. As it happens, the VSS SDK comes with just such a tool: vshadow. vshadow seems [...]]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;m trying to track down an elusive bug that only presents at a single customer site.  We&#8217;ve narrowed it to something having to do with VSS, so now I need to force some VSS snapshots outside of our product.  As it happens, the VSS SDK comes with just such a tool: <code>vshadow</code>.  <code>vshadow</code> seems to have options to exercise just about every facet of the complex VSS API, which makes it a handy test probe.  Just one problem; the version that ships with the VSS SDK is for Visual C++ 2005, and won&#8217;t build when put through VS 2k5.</p>
<p>Yes, yes, I know, binaries are included with the release.  But what if you want to debug, or modify the code, or copy-paste it and get it to build in your own code?  You&#8217;re screwed to the wall, that&#8217;s what.  Here&#8217;s the secret handshake to get it building.</p>
<p>To start with, you go through the usual conversion wizard stuff.  You build the XP version of the tool, which is missing some features.  That builds fine, albeit with a torrent of scary security warnings.  If you&#8217;re not willing to rewrite the code to use the new more-securer security APIs, add <code>_CRT_SECURE_NO_WARNINGS</code> to the list of preprocessor definitions.</p>
<p>That&#8217;s all fine, but let&#8217;s say you want to build the &#8216;Server&#8217; version, which contains VSS features available only in Windows Server 2003.  Well, in addition to the warnings you fixed above, you get this steamer:</p>
<pre><code>1&gt;revert.obj : error LNK2019: unresolved external symbol "long __stdcall ShouldBlockRevert(wchar_t const *,bool *)" (?ShouldBlockRevert@@YGJPB_WPA_N@Z) referenced in function "public: void __thiscall VssClient::RevertToSnapshot(struct _GUID)" (?RevertToSnapshot@VssClient@@QAEXU_GUID@@@Z)
1&gt;C:\Program Files\Microsoft\VSSSDK72\TestApps\vshadow\bin\Debug-Server/vshadow.exe : fatal error LNK1120: 1 unresolved externals
</code></pre>
<p>Not.  Helpful.</p>
<p>As it happens, I ran <code>dumpbin /exports</code> on <code>vssapi.lib</code>, and found that it does export <code>ShouldBlockRevert</code>, but thanks to C++ name mangling the mangled name is different.  Why is it different?  Because in <code>vssapi.lib</code>, the first argument to <code>ShouldBlockRevert</code> isn&#8217;t <code>wchar_t</code>, it&#8217;s <code>unsigned short</code>.  &#8220;So what&#8221;, you&#8217;re thinking, &#8220;they&#8217;re equivalent&#8221;.  And I don&#8217;t disagree, but the compiler treats them as different types for name manging purposes.  What&#8217;s the fix?  Well, disable the intrinsic <code>wchar_t</code> type in the C/C++ Language property page in the project properties (equivalent to the <code>/Zc:wchar_t-</code> switch if you&#8217;re one of the two people on the planet who build Visual C++ projects with makefiles).</p>
<p>Once that&#8217;s done, the <code>LPCWSTR</code> macro is defined to <code>unsigned short</code>, name mangling matches, planets align, and you can link.  QED.</p>
]]></content:encoded>
			<wfw:commentRss>http://apocryph.org/2007/09/04/incredibly_annoying_gotcha_building_vshadow_sample_visual_studio_2005/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Visual Studio Remote Debug Monitor: If I didn&apos;t love it so much, I&apos;d hate it</title>
		<link>http://apocryph.org/2006/09/13/visual_studio_remote_debug_monitor_if_i_didnt_love_it_so_much_id_hate_it/</link>
		<comments>http://apocryph.org/2006/09/13/visual_studio_remote_debug_monitor_if_i_didnt_love_it_so_much_id_hate_it/#comments</comments>
		<pubDate>Wed, 13 Sep 2006 20:47:29 +0000</pubDate>
		<dc:creator>anelson</dc:creator>
				<category><![CDATA[Migrated from Drupal]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[msvsmon]]></category>
		<category><![CDATA[tech diary]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://apocryph.org/?p=276</guid>
		<description><![CDATA[In my new job I do alot of work with low-level device drivers that can badly shitcan one&#8217;s machine if something goes wrong (as it so often does). Thus, it was something of a no-brainer to run my development binaries within a VMWare virtual machine. However, this does lead to some unfortunate complexity. One of [...]]]></description>
			<content:encoded><![CDATA[<p>In my new job I do alot of work with low-level device drivers that can badly shitcan one&#8217;s machine if something goes wrong (as it so often does).  Thus, it was something of a no-brainer to run my development binaries within a <a href="http://www.vmware.com/">VMWare</a> virtual machine.</p>
<p>However, this does lead to some unfortunate complexity.  One of the most significant of these is the need to use the debugger on my host machine, to debug code on the virtual machine.</p>
<p>Since Visual C++ 6.0 at least, I&#8217;ve known of the Remote Debug Monitor, which is a lightweight executable shipped with Visual C++ that you run on a target machine to enable you to debug processes thereon, from a remote host across the network.  It&#8217;s gone through various stages of shittiness, and now operates primarily via DCOM (presumably, using sockets was too reliable and straightforward).</p>
<p>If you&#8217;ve ever coded with DCOM, you probably sense I&#8217;m about to relate a tale of misery and woe.  DCOM sucks for a few reasons:</p>
<ul>
<li>Its security model is only fully understood by <a href="http://pluralsight.com/blogs/keith/">Keith Brown</a>, and even he&#8217;s forgotten alot of it now that no one uses DCOM anymore.</li>
<li>When something goes wrong (and it always does with DCOM) the error message you get is typically something like &#8220;Error -8234286245: You&#8217;re shit out of luck&#8221;.</li>
<li>The parts of it that matter are virtually undocumented, leaving you with few options but to scrounge ten year old USENET postings for stupid hacks that no one understands but that seemed to work for a guy in Brazil once.</li>
</ul>
<p>Add to this the fact that you&#8217;re trying to get a remote debugger to work on <em>top</em> of DCOM, and it&#8217;s fairly obvious that your day is about to get a whole lot worse.</p>
<h2>Installation</h2>
<p>To start, you need to get the Remote Debug Monitor installed on the machine running the process you want to debug.  The MSDN article <a href="http://msdn2.microsoft.com/en-us/library/bt727f1t.aspx">Howto: Setup Remote Debugging</a>, is fairly comprehensive, albeit a bit dense.</p>
<p>The gist is, either install Visual Studio 2005, or install the RDM separately from the Visual Studio 2005 installation media.  Since I&#8217;m running on a VM that is supposed to roughly approximate a real-world environment, I&#8217;m not about to install VS2k5, so I opted for the separate install.  It&#8217;s in the <code>Remote Debugger</code> folder, with subfolders for the <code>x86</code>, <code>x64</code>, and <code>ia64</code> platforms.</p>
<p>The installer gives you the option to run the monitor as a service; I declined, and run it explicitly from a shortcut I put on my desktop, when I need remote debugging.</p>
<h3>XP SP2 and Firewalls</h3>
<p>If you have the misfortune of running XP SP2 or a personal firewall, you&#8217;ve some work to do.  The aforementioned article enumerates all the ports you have to open.  Port tcp/135 on the machine you debug from; tcp/135, tcp/139, tcp/445, udp/137, and udp/138 on the machine running the debug monitor.  There are also a couple of IPsec ports if you use IPsec, which I don&#8217;t.</p>
<p>Intuitively, you might expect only the remote machine would need firewall rule changes, but the magic of DCOM means there are comms in both directions.  Forget this at your peril.</p>
<p><a href="http://support.microsoft.com/default.aspx?scid=kb;%5BLN%5D;833977">KB 833977</a> has some additional steps to try on XP SP2.</p>
<h2>Running</h2>
<p>When you&#8217;re ready to do some debugging on the remote host, startup the debug monitor.  By default it will run with Windows authentication, which also seems to mean DCOM.  You can switch it out of this mode, but the resulting dumbed-down TCP-based mode doesn&#8217;t support managed debugging, which makes it a non-starter for a .NET programmer such as myself.  Accept the defaults.</p>
<p>How you configure Visual Studio to use the remote debugger depends on what kind of project you&#8217;re trying to debug.  Visual C++ projects have a drop-down box in the Debugging section of the project Properties dialog, which defaults to &#8216;Local Windows Debugger&#8217;; change that to &#8216;Remote Windows Debugger&#8217;, and fill out the debug fields as appropriate, taking care to enter the name or IP address of the machine running the debug agent, in the &#8216;Remote Server Name&#8217; field.  &#8216;Connection&#8217; and &#8216;Debugger Type&#8217; leave at their defaults.</p>
<p>.NET projects have a completely different project properties screen; go to the Debug tab, check the &#8216;Use remote machine&#8217; checkbox, and enter the remote machine name.</p>
<p>A few things to note, regardless of which type of project you&#8217;re debugging:</p>
<ul>
<li>The command/external program to run is evaluated on the <em>remote machine</em>, so the path you specify must be valid <em>on that machine</em>.  Specifying the path to the executable on your Visual Studio machine won&#8217;t work, unless by some happy coincidence they&#8217;re the same.</li>
<li>Ditto for any paths or file names given as command line arguments</li>
<li>It&#8217;s imperative that the remote machine have the exact binaries you just built with Visual Studio.  If not, the debugger will detect that its symbols don&#8217;t match the binaries, and breakpoints won&#8217;t work, not to mention any changes you made since you last updated the remote host won&#8217;t be there.  Do not mess this up.</li>
</ul>
<p>At this point, kick off the debugger with F5.  If you&#8217;re very lucky, things will Just Work.  If not, consider the troubleshooting steps below:</p>
<h2>Gotchas</h2>
<p>The real problem with the Visual Studio&#8217;s remote debugging support is that it doesn&#8217;t provide much in the way of useful error messages; it either works or claims there&#8217;s no remote debug monitor running on the target.</p>
<p>To that end, try the following steps:</p>
<ul>
<li>If at all possible, make sure the username and password are the same on both the host and the remote machine.</li>
<li>According to <a href="http://msdn2.microsoft.com/en-us/library/z3bxds0s.aspx">Remote Debugging Permissions</a> you can remotely debug a process owned by the account you authenticate with to the remote debug agent.  I run without admin privs on my host machine, but I&#8217;ve never tried to run the debug monitor without admin rights, so ymmv.</li>
<li>DCOM privs may get in the way.  Adjust the DCOM privs as specified in <a href="http://msdn2.microsoft.com/en-us/library/x1719157.aspx">this article</a> on the remote machine.</li>
<li><a href="http://support.microsoft.com/kb/908099/en-us">KB 908099</a>, though ostensibly for XP SP2, is mostly applicable to W2k3 server as well (<em>sans</em> the firewall stuff, obviously).  Pay particular attention to the <code>dcomcnfg</code> steps</li>
<li>Sometimes the Visual Studio remote debug code doesn&#8217;t use the right username to find the remote debug monitor instance.  In my case, the host and remote machines were both running as <code>administrator</code>, but the remote machine was running under a domain <code>administrator</code> account for a domain controlled by the remote machine itself, and Visual Studio reported:
<pre>
 Unable to start debugging.</pre>
<p>The Microsoft Visual Studio Remote Debugging Monitor (MSVSMON.EXE) does not appear to be running on the remote computer. Please see Help for<br />
 assistance.</p>
<p>This despite the fact that the agent was indeed running.  In this case, try explicitly specifying the user name running the debug monitor.  So, if your remote machine is &#8216;buggy&#8217;, run the remote debug monitor, and look at the first line of output it produces.  It should look something like:</p>
<p><code>Msvcmon started a new server named 'WHATEVER\someone@buggy'.  Waiting for new connections</code></p>
<p>Back in the Visual Studio debug settings, specify that entire quoted string (without quotes, obviously) as the hostname.  Everything before the &#8216;@&#8217; will be interpreted as the username.</li>
<li>Finally, if it just won&#8217;t work, try to simplify the situation as much as possible.  Make sure the usernames and passwords match, that both ends are admins, etc.  If all else fails, you can switch the debug monitor and Visual Studio to use the native mode without authentication (See Tools|Options), but this won&#8217;t allow managed debugging, so if you&#8217;re writing .NET code you&#8217;re screwed.</li>
</ul>
<p>Good luck, and godspeed.  You&#8217;ll need both.</p>
]]></content:encoded>
			<wfw:commentRss>http://apocryph.org/2006/09/13/visual_studio_remote_debug_monitor_if_i_didnt_love_it_so_much_id_hate_it/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Another maddening Visual C++ bug</title>
		<link>http://apocryph.org/2006/07/31/another_maddening_visual_c_bug/</link>
		<comments>http://apocryph.org/2006/07/31/another_maddening_visual_c_bug/#comments</comments>
		<pubDate>Tue, 01 Aug 2006 03:09:49 +0000</pubDate>
		<dc:creator>anelson</dc:creator>
				<category><![CDATA[Migrated from Drupal]]></category>
		<category><![CDATA[sucks]]></category>
		<category><![CDATA[tech diary]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://apocryph.org/?p=258</guid>
		<description><![CDATA[I&#8217;ve run across some infuriating Visual C++/vcbuild behavior that, as it turns out, is a bug that was &#8220;just found too late to make it into the 2005 product. [Microsoft] will most certainly be addressing it as soon as we possibly can&#8221; The gist of it? If you have a solution with two or more [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve run across some infuriating Visual C++/<code>vcbuild</code> behavior that, as it turns out, is a <a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101919">bug that was &#8220;just found too late to make it into the 2005 product. [Microsoft] will most certainly be addressing it as soon as we possibly can&#8221;</a></p>
<p>The gist of it?  If you have a solution with two or more DLL projects, one dependent upon the other, and you use the &#8220;Link Library Dependencies&#8221; linker option to automatically link against the lib produced by the project being dependened upon, the IDE will compile and link find but <code>vcbuild</code> (and <code>msbuild</code>) will fail to link.  Upon inspecting the build log, you see that the library that should&#8217;ve been linked in is not.</p>
<p>So, add that to the growing pile of shit that never should&#8217;ve made it into RTM and will be fixed in the next version of Visual Studio.</p>
]]></content:encoded>
			<wfw:commentRss>http://apocryph.org/2006/07/31/another_maddening_visual_c_bug/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>&quot;The object is currently in use elsewhere.&quot;</title>
		<link>http://apocryph.org/2005/10/12/the_object_is_currently_in_use_elsewhere/</link>
		<comments>http://apocryph.org/2005/10/12/the_object_is_currently_in_use_elsewhere/#comments</comments>
		<pubDate>Wed, 12 Oct 2005 19:54:15 +0000</pubDate>
		<dc:creator>anelson</dc:creator>
				<category><![CDATA[Migrated from Drupal]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[prospertine]]></category>
		<category><![CDATA[tech diary]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://apocryph.org/?p=18</guid>
		<description><![CDATA[I&#8217;m having trouble opening a particular WinForms form in my project using the Visual Studio 2k3 designer. The designer loads, and I see the form, but immediately a message box appears: The object is currently in use elsewhere. Upon dismissing the box, the designer remains active, but the form itself is displayed mostly as a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m having trouble opening a particular WinForms form in my project using the Visual Studio 2k3 designer.  The designer loads, and I see the form, but immediately a message box appears:</p>
<blockquote><p>
The object is currently in use elsewhere.
</p></blockquote>
<p>Upon dismissing the box, the designer remains active, but the form itself is displayed mostly as a white blob, and it clearly in some sort of corrupted state.<br />
A Google yields <a href="http://support.microsoft.com/?kbid=838463">KB 838463</a>, uselessly entitled &quot;&quot;System.InvalidOperationException&quot; error message when you use a program that changes the display orientation in Windows XP Tablet PC Edition&quot;.  Needless to say, I&#8217;m neither changing the display orientation or running XP Tablet PC Edition.  Next.<br />
From a <a href="http://groups.google.com/group/microsoft.public.dotnet.framework.windowsforms/browse_thread/thread/6aa434738411c40a/764fcea3161aea0a?lnk=st&amp;q=visual+studio+designer+%22The+object+is+currently+in+use+elsewhere%22&amp;rnum=2&amp;hl=en#764fcea3161aea0a">Google Groups hit</a>:</p>
<blockquote><p>
This is the common response of the system when it finds a problem with a control at design time. Your grid control build may be out of date or may have failed or the control may be active in the designer toolbox so that it cannot be written to by the build process.
</p></blockquote>
<p>I&#8217;m not really buying that; none of those apply to me.  I&#8217;ll try restarting VS2k3.<br />
Interestingly, VS2k3 crashed when I closed it, further supporting my theory that VS2k3 is just confused.<br />
Aha, after a restart all is well.  Oh how I love VS2k3.</p>
]]></content:encoded>
			<wfw:commentRss>http://apocryph.org/2005/10/12/the_object_is_currently_in_use_elsewhere/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
