<?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>hamang.net &#187; Visual Studio</title>
	<atom:link href="http://hamang.net/tag/visual-studio/feed/" rel="self" type="application/rss+xml" />
	<link>http://hamang.net</link>
	<description>- the everyday life</description>
	<lastBuildDate>Wed, 10 Feb 2010 09:52:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Use regular expressions in Visual Studio to clean up code</title>
		<link>http://hamang.net/2009/02/20/use-regular-expressions-in-visual-studio-to-clean-up-code/</link>
		<comments>http://hamang.net/2009/02/20/use-regular-expressions-in-visual-studio-to-clean-up-code/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 12:30:41 +0000</pubDate>
		<dc:creator>Knut Hamang</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://hamang.net/?p=191</guid>
		<description><![CDATA[This is a reminder to myself. 
Knut, remember that Regular Expressions are very handy to clean up a lot of messy code. 
Here is an example:
The following function call results in a code analysis warning:
DBHelper.SetPropertyFromDB(m_City, dr(&#034;CITY&#034;))
It&#039;s a helper function that returns the typed value from a DBValue. Not really useful these days with NHibernate or [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a reminder to myself. </em></p>
<p><strong>Knut, remember that Regular Expressions are very handy to clean up a lot of messy code. </strong></p>
<p>Here is an example:<br />
The following function call results in a code analysis warning:</p>
<p style="font-family: Courier New,Courier,mono;">DBHelper.SetPropertyFromDB(m_City, dr(&#034;CITY&#034;))</p>
<p>It&#039;s a helper function that returns the typed value from a DBValue. Not really useful these days with NHibernate or Typed Datasets, but it&#039;s code from an old application. Here is the signature of the code:</p>
<p style="font-family: Courier New,Courier,mono;">Shared Sub SetPropertyFromDB(ByRef pProperty As Object, ByVal value As Object)</p>
<p>The warning reported is:</p>
<p><em>&#034;Warning: Implicit conversion from &#039;Object&#039; to &#039;String&#039; in copying the value of &#039;ByRef&#039; parameter &#039;pProperty&#039; back to the matching argument.&#034;</em></p>
<p>To fix this, I created a new method that returns the correct typed value instead of returning the referenced parameter and marked the old method &#034;Obsolete&#034;:</p>
<p style="font-family: Courier New,Courier,mono;">Public Shared Function GetDBValue(ByVal pProperty As Object, ByVal dbValue As Object) As Object</p>
<p>Now, I had to rewrite all the calls to the function (several hundred calls). This included returning the typed value into the same variable as the first parameter in the function call, like this:</p>
<p style="font-family: Courier New,Courier,mono;">m_City = DBHelper.GetDBValue(m_City, dr(&#034;CITY&#034;))</p>
<p>This is easily achieved by using Regular Expressions in the &#034;Find and Replace&#034; dialog in Visual Studio:</p>
<p>Find What:</p>
<p style="font-family: Courier New,Courier,mono;">DBHelper.SetPropertyFromDB\({.*},</p>
<p>(note: the \ escapes the ( and the expression group is marked by a {})</p>
<p>Replace with:</p>
<p style="font-family: Courier New,Courier,mono;">\1 = DBHelper.GetDBValue(\1,</p>
<p>(note: the \1 will represent the expression group)</p>
<p>Pretty simple, and very powerful  <img src='http://hamang.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://hamang.net/2009/02/20/use-regular-expressions-in-visual-studio-to-clean-up-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bug: VS 2008 &#8211; Web Application Project opened as Web Site</title>
		<link>http://hamang.net/2008/11/03/bug-vs-2008-web-application-project-opened-as-web-site/</link>
		<comments>http://hamang.net/2008/11/03/bug-vs-2008-web-application-project-opened-as-web-site/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 12:44:28 +0000</pubDate>
		<dc:creator>Knut Hamang</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://hamang.net/?p=153</guid>
		<description><![CDATA[I just bumped into a weird Visual Studio (aka. Vicious Studio)  bug. Not the first, but this is a pretty annoying one. I have taken an old .NET 1.1 Web application and converted it to .NET 3.5 using the VS Conversion Wizard. Everything seems ok, and I convert to Web Site to a Web Application [...]]]></description>
			<content:encoded><![CDATA[<p>I just bumped into a weird Visual Studio (aka. Vicious Studio)  bug. Not the first, but this is a pretty annoying one. I have taken an old .NET 1.1 Web application and converted it to .NET 3.5 using the VS Conversion Wizard. Everything seems ok, and I convert to Web Site to a Web Application Project. No problems so far. I fix some issues, close the solution, do some other stuff. Some days later I open the solution again. I then have about 200 errors and the Web Application Project is opened as a Web Site. Also the designer and resx files are not connected to the asp and codebehind files:</p>
<p><a href="http://hamang.net/wp-content/uploads/2008/11/proj_err.png"><img class="size-full wp-image-155 alignnone" title="disconnected files" src="http://hamang.net/wp-content/uploads/2008/11/proj_err.png" alt="" width="255" height="81" /></a></p>
<div style="clear:both;">It&#039;s not possible to change the project type in Visual Studio, as the project does not have a &#034;properties&#034; context menu item. The only option in the context menu is &#034;property pages&#034; as with regular web sites. Visual Studio actually thinks it&#039;s a Web Site and not a Web Application project anymore. The other missing context menu option is the &#034;Convert to Web Application&#034;. So Visual Studio thinks it&#039;s a Web Site that cannot be converted to a Web Application Project. Not surprisingly as I converted the Web Site to a Web Application Project right after the Conversion Wizard.</p>
<p>Ok, I have to start digging into the project and solution files. Comparing them to other solutions using Web Application project files, I can&#039;t seem to find anything suspicious. After some googling with no result, I decide to stare at the screen for a while and use WinMerge to determine what the difference might be. Suddenly I find one minor difference:</p>
<p>The solution file that works:</p>
<p><em>Project(&#034;{F184B08F-C81C-45F6-A57F-5ABD9991F28F}&#034;) = &#034;Clock&#034;, &#034;Clock.vbproj&#034;, &#034;{3B3D0F02-D310-4BFB-83AD-F62758BB8624}&#034;</em></p>
<p>The one that fails:</p>
<p><em>Project(&#034;{F184B08F-C81C-45F6-A57F-5ABD9991F28F}&#034;) = &#034;Calendar&#034;, &#034;Calendar\&#034;, &#034;{7B411329-B1CB-457F-A954-898DX16B85A6}&#034;</em></p>
<p>That&#039;s it. The Calendar project reference is missing the whole path to the project file. When i change it to:</p>
<p><em>Project(&#034;{F184B08F-C81C-45F6-A57F-5ABD9991F28F}&#034;) = &#034;Calendar&#034;, &#034;<strong>Calendar\Calendar.vbproj</strong>&#034;, &#034;{7B411329-B1CB-457F-A954-898DX16B85A6}&#034;</em></p>
<p>it opens as a Web Application Project, and now the resx and designer files are properly connected:</p></div>
<p><a href="http://hamang.net/wp-content/uploads/2008/11/proj_ok.png"><img class="alignnone size-full wp-image-156" title="files connected" src="http://hamang.net/wp-content/uploads/2008/11/proj_ok.png" alt="" width="248" height="96" /></a></p>
<div style="clear:both;">There might be other issues causing this behaviour, but at least this solved my problem. This is just the everyday life using Visual Studio. Actually I think it&#039;s a great IDE, but there are some strange behaviours now and then.</div>
<div style="clear:both;"></div>
<div style="clear:both;"><strong>Update </strong>- In some occasions you might wan&#039;t to remove the .webinfo file. This file can be causing this behaviour.  Just remove it and instead set the startup path for your application in properties for the Web Application project.</div>
]]></content:encoded>
			<wfw:commentRss>http://hamang.net/2008/11/03/bug-vs-2008-web-application-project-opened-as-web-site/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
