<?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>DotBert &#187; bug</title>
	<atom:link href="http://dotbert.loedeman.nl/category/bug/feed" rel="self" type="application/rss+xml" />
	<link>http://dotbert.loedeman.nl</link>
	<description>.NET thoughts by Bert Loedeman</description>
	<lastBuildDate>Thu, 18 Mar 2010 12:49:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The using statement and XmlReader.Create</title>
		<link>http://dotbert.loedeman.nl/the-using-statement-and-xmlreadercreate</link>
		<comments>http://dotbert.loedeman.nl/the-using-statement-and-xmlreadercreate#comments</comments>
		<pubDate>Mon, 07 Sep 2009 11:29:43 +0000</pubDate>
		<dc:creator>Bert Loedeman</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[visual studio 2008]]></category>

		<guid isPermaLink="false">http://dotbert.loedeman.nl/?p=150</guid>
		<description><![CDATA[Are you also fond of using the using statement (e.g. when dealing with streams)? I am, since it kind-of guarantees me that streams are closed when I think they should be closed, even if I do not specify the Dispose() command. You probably noticed the &#8216;kind-of guarantee&#8217; part. You are right, this is not always [...]]]></description>
			<content:encoded><![CDATA[<p>Are you also fond of using the using statement (e.g. when dealing with streams)? I am, since it kind-of guarantees me that streams are closed when I think they should be closed, even if I do not specify the Dispose() command. You probably noticed the &#8216;kind-of guarantee&#8217; part. You are right, this is not always the case. It took me a while to find out the the following is not going to work as smooth as expected:</p>
<pre class="brush: csharp;">
using (var reader = XmlReader.Create(File.Open(fileName, FileMode.Open)))
    { ... }
</pre>
<p>You probably wonder what&#8217;s the problem of the code printed above. I don&#8217;t see it too, however, I know there is a problem related to this code. The problem lies in the Create overload used in the example code. It uses default XmlReaderSettings. Unfortunately, this settings do not include having the CloseInput property set to true. You can do the math: no closed file at all! That&#8217;s a guarantee for having troubles on the file &#8216;being in use already&#8217;.</p>
<p>The solution to this problem is quite simple:</p>
<pre class="brush: csharp;">
using (XmlReader reader = XmlReader.Create(File.Open(path, FileMode.Open),
         new XmlReaderSettings { CloseInput = true })) { ... }
</pre>
<p>How can we call this? A &#8216;bug&#8217;? No, at least not technically spoken. Since the XmlReader creates the stream, it should close it too. The case is, you should not expext it knowing the using statement as most people know it (fail-proofing your code). Since I know this, I am a little bit scared about using using statements without calling the stream&#8217;s constructor. You can do so, but be sure it does what you expect it to do&#8230; In my opinion, the using statement still remains very helpful, please I do not consider it being as perfect as I thought it to be for years <img src='http://dotbert.loedeman.nl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' title="The using statement and XmlReader.Create" />  &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://dotbert.loedeman.nl/the-using-statement-and-xmlreadercreate/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solution: The operation could not be completed. Invalid FORMATETC structure</title>
		<link>http://dotbert.loedeman.nl/solution-the-operation-could-not-be-completed-invalid-formatetc-structure</link>
		<comments>http://dotbert.loedeman.nl/solution-the-operation-could-not-be-completed-invalid-formatetc-structure#comments</comments>
		<pubDate>Thu, 02 Jul 2009 13:29:15 +0000</pubDate>
		<dc:creator>Bert Loedeman</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[aspx]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[visual studio 2005]]></category>
		<category><![CDATA[visual studio 2008]]></category>

		<guid isPermaLink="false">http://dotbert.loedeman.nl/?p=94</guid>
		<description><![CDATA[This morning I ran into a ASP.NET bug in Visual Studio. Dragging a custom server control on an aspx file was not possible since I had &#8216;an invalid FORMATETC structure&#8217; (what the &#8230;. is that?!). The message box alerting me something is really really wrong is this one:


Trying to solve the bug, I  found the following [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">This morning I ran into a ASP.NET bug in Visual Studio. Dragging a custom server control on an aspx file was not possible since I had &#8216;an invalid FORMATETC structure&#8217; (what the &#8230;. is that?!). The message box alerting me something is really really wrong is this one:</p>
<div style="text-align: center;"><a href="http://dotbert.loedeman.nl/wp-content/uploads/2009/07/FORMATETC-problem.jpg" rel="shadowbox[post-94];player=img;"></a></div>
<p style="text-align: center;"><img class="size-full wp-image-95 aligncenter" title="The FORMATETC bug" src="http://dotbert1.loedeman.nl/wp-content/uploads/2009/07/FORMATETC-problem.jpg" alt="The FORMATETC bug" width="408" height="119" /></p>
<p>Trying to solve the bug, I  found the following attribute to be the problem: [ToolboxItem(true)]. Just delete the attribute, rebuild the application and the problem/bug disappears!</p>
<p>Good luck! Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://dotbert.loedeman.nl/solution-the-operation-could-not-be-completed-invalid-formatetc-structure/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2005 and the vaporized Immediate Window</title>
		<link>http://dotbert.loedeman.nl/visual-studio-2005-and-the-vaporized-immediate-window</link>
		<comments>http://dotbert.loedeman.nl/visual-studio-2005-and-the-vaporized-immediate-window#comments</comments>
		<pubDate>Fri, 19 Dec 2008 14:49:00 +0000</pubDate>
		<dc:creator>Bert Loedeman</dc:creator>
				<category><![CDATA[bug]]></category>
		<category><![CDATA[immediate window]]></category>
		<category><![CDATA[visual studio 2005]]></category>

		<guid isPermaLink="false">http://www.loedeman.net/wordpress/?p=25</guid>
		<description><![CDATA[
Today I reinstalled my development virtual machine. For a couple of &#8216;legacy&#8217; software packages I must have Visual Studio 2005 installed as well. Debugging one of those software packages mentioned above, I wanted to &#8216;hack my runtime&#8217; using the Immediate Window. It wasn&#8217;t there!
Since I always have the Immediate Window activated, I cannot remember the [...]]]></description>
			<content:encoded><![CDATA[<div>
<div>Today I reinstalled my development virtual machine. For a couple of &#8216;legacy&#8217; software packages I must have Visual Studio 2005 installed as well. Debugging one of those software packages mentioned above, I wanted to &#8216;hack my runtime&#8217; using the Immediate Window. It wasn&#8217;t there!</div>
<div>Since I always have the Immediate Window activated, I cannot remember the shortcut for it (Ctrl+Alt+I <img src='http://dotbert.loedeman.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="Visual Studio 2005 and the vaporized Immediate Window" /> ). Looking for the menu item to activate it (yes, of course, in the Debug menu) it appeared to be gone. Sadly this is a known bug. The only way to get it back into the menu is using the Tools menu, click Customize, select the Commands tab, choose for Debug commands and drag Immediate onto the toolbar.</div>
<div style="text-align: left;">For some kind of overview:</div>
<div><img class="size-full wp-image-205 aligncenter" title="The disappeared immediate window" src="http://dotbert1.loedeman.nl/wp-content/uploads/2008/12/The-disappeared-immediate-window.jpg" alt="Visual Studio 2005 and the vaporized Immediate Window The disappeared immediate window" width="302" height="400" /></div>
<div>I simply assume nobody likes it either <img src='http://dotbert.loedeman.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="Visual Studio 2005 and the vaporized Immediate Window" />  &#8230;</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://dotbert.loedeman.nl/visual-studio-2005-and-the-vaporized-immediate-window/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
