Apr
12
2010

Visual Studio 2010 Released – Version Comparison

Well, I think we all know that Visual Studio 2010 dropped today. That is old news…
What I found to be difficult was finding which version I needed to be downloading and installing from MSDN….

Took me a while, but I finally found the nice page which outlined the differences and how they are available to MSDN subscribers.

http://www.microsoft.com/visualstudio/en-us/products

Pretty self explanatory, yet it took me 30 minutes to find it though… Maybe this will help the other ignoramuses out there…

Enjoy!

Apr
4
2010

Working with .NET Configuration Connection Strings at Runtime

image On occasion we may have a request to build out simple little validation tools for testers and or project managers. These types of requests typically require the ability to run the tool against multiple environments; development, QA, stage, and production sometimes. With a configuration file in place, the instance of managing connection strings is very simple with .NET.

The System.Configuration.ConfigurationManager class has all the facilities necessary to make this a reality.


Let’s say our simple little WinForms “validation” app has a combobox where our tester’s can select which environment the validation is to run;

 

image

 

The user can select which environment they would like to use, then click a button, for example. Now, some might digress here and get into a debate on convention over configuration, but this is a silly little sample, a means to an end, which software development is and nothing more… So, that being said, here is what our app.config file may look like. A simple connection string the db for which we are attempting to connect to.

 

 

   1: <connectionStrings>
   2:  
   3:   <add name="MyConnString" 
   4:        connectionString="Data Source=localhost;Initial Catalog=MyDb;Persist Security Info=True;User ID=FakeUser;Password=FakePwd" />
   5:  
   6: </connectionStrings>

 

Easy-peasy… Now, at runtime we want to be able to alter this setting. The ConfigurationManager class is our hero to the rescue here in 3 lines of code;

 

   1: internal static void SetConnectionStrin(string connectionStringName,string newConnectionStringValue)
   2: {
   3:    var cnfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
   4:    cnfg.ConnectionStrings.ConnectionStrings[connectionStringName].ConnectionString = newConnectionStringValue;
   5:    cnfg.Save();
   6:    ConfigurationManager.RefreshSection("connectionStrings");
   7: }

 

What is important to note here is the call to the RefreshSection method once the change is saved. The reason for this is that when the app is started the configuration is read from the config file into memory for fast access and unless you call this method, you will retrieve stale values after your call to Save().

What is cool about this is here you have an example for not only connection string, but the same can concept can be used for application settings as well. In that instance you would call AppSettings instead of ConnectionStrings of course.


Enjoy!

Mar
6
2010

Visual Studio 2008 Toggle Visible Whitespace

While coding the other day I was getting a little sloppy on the keyboard today with some serious butter fingers while working in Visual Studio.

After a slip of the fingers my code view looked like this;

VS_WhiteSpaces

At first my first thought was COOL! Kind of like the view formatting button in Word…

Then, as I began to dig through the VS Text Editor settings attempting to find out just what the heck I did. I quickly became a little disgruntled with this obligatory detour as the stumped period duration began to rack up…

Whitespace is typically not something I care about when coding in Visual Studio, but this will come in handy when opening those whacky PHP files, or other formats…

So how did I do it?

After a few search engine queries, Ctrl E + S is the shortcut I slipped on which toggle this view.

Additionally, this can be found in the Edit Menu under Advanced here;

text_advanced_setting

Maybe this will come in handy for someone out there, if just to toggle it back at least.

~Enjoy!

Nov
30
2009

LINK: USPS Address Service API

usps A good buddy of mine built out a very nice API for interfacing with the USPS Address service. If you are building an ecommerce site, then I suggest you check out Matt Mather’s nice USPS Address API implementation here;

http://www.dotnetvision.com/archive/2009/10/11/u.s.p.s-web-tools-address-services-class-library.aspx

A well written, unit tested, example of how to interface with the US Postal Services web services!

Enjoy!

Nov
19
2009

What is a DEVELOPEMENT environment for?

dev Recently working on revamping our shop, from top to bottom, and someone asked me why a developer shouldn’t be working off of shared database environment and I replied…

“Our Developers should work in an isolated environment to protect themselves from kicking each other in the head.

“A Dev environment is where all developers’ work is integrated prior to QA once stable, so we don't kick the QA team in the head.”

“A QA environment is where testing can be done so we all do not kick the end users in the head!

“A production environment is the sacred grounds where our apps  make us the money!”

They replied, “Oh… Ok…”

Enjoy!

Nov
13
2009

Gems of Ignorance #1: Response.Write JS Redirect?

ignorance

This is great… A co-worker of mine found this little Gem in a legacy Classic ASP app at my company the other day and I am still chuckling about it…

   1: if trim(session("Loginname"))="" then
   2:     response.Write("<html>")
   3:     response.Write("<body onLoad='Javascript:document.frm.submit();'>")
   4:     response.Write("<form action='../userLogin.asp' name='frm' method='post' target='_parent'>")
   5:     response.Write("</form>")
   6:     response.Write("</body>")
   7:     response.Write("</html>")
   8:     response.end()
   9: end if

 

 

You can always rely on ignorance for a good laugh, or cry depending on the situation. This is certainly a laughable one. I imagine this coder spent a few hours drafting up this programmatic feat and walked away proud. Hope they have since discovered the better ways to accomplish this…

Enjoy!

Sep
28
2009

TeamCity 5.0 (Darjeeling): NCover & PartCover packed in!

The upcoming release of TeamCity (codename Darjeeling) is proving to have some nice new features under the covers. One of those areas of improved integration is in Code Coverage Analysis tools. Now, NCover and PartCover are full fledged members of the Build Runner configuration!!!

Here’s a glimpse in the Build Runner Configuration page under an MSBuild Runner;

Coverage

This is a great way to slim down your build scripts if you use them.
Here is the NCover options;

ncover_details

 

And the PartCover options view;

partcover_details

This is a really nice feature in the new TeamCity! Can help in trimming down the amount of XML you have to deal with.

Check out the EAP (Early Access Program) of TeamCity 5.0!

Much more to come!

Aug
24
2009

Roy Osherove is giving an hands-on TDD Masterclass

Roy Osherove is giving an hands-on TDD Masterclass in the UK, September 21-25. Roy is author of "The Art of Unit Testing" (http://www.artofunittesting.com/), a leading tdd & unit testing book; he maintains a blog at http://iserializable.com (which amoung other things has critiqued tests written by Microsoft for asp.net MVC - check out the testreviews category) and has recently been on the Scott Hanselman podcast (http://bit.ly/psgYO) where he educated Scott on best practices in Unit Testing techniques. For a further insight into Roy's style, be sure to also check out Roy's talk at the recent Norwegian Developer's Conference (http://bit.ly/NuJVa). 

Full Details here: http://bbits.co.uk/tddmasterclass

bbits are holding a raffle for a free ticket for the event. To be eligible to win the ticket (worth £2395!) you MUST paste this text, including all links, into your blog and email Ian@bbits.co.uk with the url to the blog entry.  The draw will be made on September 1st and the winner informed by email and on bbits.co.uk/blog

Jul
21
2009

SQL QT #2: TSQL CSV string to Table Function

So, not sure where I found this, but thought it would be helpful to post here. This is a very helpful little SQL table valued function to split out CSV strings into a table. I have used it in a few odd places and eliminated huge head aches!

ALTER FUNCTION [dbo].[CSVToTable]
(
       @psCSString VARCHAR(MAX)
)
RETURNS @otTemp TABLE(ID VARCHAR(25))
AS
BEGIN
 
       DECLARE @sTemp VARCHAR(10)
 
       WHILE LEN(@psCSString) > 0
              BEGIN
              
                     SET @sTemp = LEFT(@psCSString, ISNULL(NULLIF(CHARINDEX(',', @psCSString) - 1, -1), LEN(@psCSString)))
              
                     SET @psCSString = SUBSTRING(@psCSString,ISNULL(NULLIF(CHARINDEX(',', @psCSString), 0), LEN(@psCSString)) + 1, LEN(@psCSString))
              
                     INSERT INTO @otTemp VALUES (LTRIM(RTRIM(@sTemp)))
                     -- kill the nulls/ empty strings
                     DELETE FROM @otTemp WHERE Id IS NULL OR Id = ''
              
              END
RETURN
END

 

Enjoy!

RA

May
31
2009

Dan Wahlin in So Cal this week…

I have been out of town for a few days and return to find out that Dan Wahlin is in town this week.

First on June 1 at UCLA for the Los Angeles .NET Developers Group Meeting discussion ASP.NET MVC

Then on Tuesday June 2nd at the LA C# Developers Group in Manhattan Beach talking about Silverlight 3.

Finally, June 3rd at the Southern California .NET Developers Group once again discussing Silverlight 3.

If you have the time, check him out!

Dan Wahlin’s – So Cal itinerary

About me...

I am a software dev specializing in web based application lovin life in So Cal!

Month List