Brendan Enrick

Daily Software Development

Visual C# 2008 Keyboard Shortcut Reference

As I've said previously, I am working with developers who are just beginning to learn the tools of the trade. They have a long way to go working with plenty of applications. All people always have more they can learn, so I'll pass along a useful reference here. I found this great reference sheet from Microsoft that has a bunch of key-bindings for Visual C# 2008. It is a PDF poster you can use to reference different shortcuts available to you.

http://www.microsoft.com/downloads/details.aspx?familyid=e5f902a8-5bb5-4cc6-907e-472809749973&displaylang=en

Change SQL Server Instance for Visual Studio Database Project

While installing SQL Server 2005 recently I ran into some difficulty. I use database projects from Visual Studio 2005 Team Edition for Database Professionals. I use Visual Studio 2008 with them now, and I recently made a mistake while using one of these projects. When I ran this project my default instance of SQL Server was not listed, so I figured I would connect it to the SQL Express. BIG MISTAKE. After installing SQL Server and getting it working correctly I removed SQL Server Express, and now the real fun begins. The database project no longer loads.

So I try removing and adding the project in my solution figuring it might prompt me for the database instance again. No luck. So I decide to ask around a bit. One forum got me a nice response. It explained how to make the change as well as linking to this MSDN article.

http://msdn2.microsoft.com/en-us/library/aa833159(VS.80).aspx

To make this change you just have to alter some settings in Visual Studio. Start by navigating to the Tools menu and choose Options.

SetValidationDatabase-Step1

Once you've opened the Options menu, navigate to the Database Tools section and pick Design-time Validation Database. This is the information for the database used by Visual Studio for database projects. Change the SQL Server Instance Name to whatever the name of the local database is.

SetValidationDatabase-Step2

I made the bad assumption of assuming that the project is what connects to the server instead of Visual Studio. I checked everywhere in settings for the project, but it slipped my mind that Visual Studio would be what would contain that setting.

As one final note I will say Googling sucks when you're looking for information about "Visual Studio 2005 Team Edition for Database Professionals". Ah what a great name guys.....

Unable to cast object of type 'Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection' to type 'Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection'

Earlier today I was trying to track down this error.

Unit Test Adapter threw exception: The type initializer for 'Microsoft.VisualStudio.TestTools.UnitTesting.TestConfiguration' threw an exception. Unable to cast object of type 'Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection' to type 'Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection'

I tried Googling for it, but I didn't find anything regarding this problem. I was pretty sure it was a VS 2008 upgrade issue, because it looks like it is a dll version issue. Since the two classes it is trying to cast between are the same class. So I must be using the wrong version of a dll and I not too long ago upgraded to VS 2008.

In the App.config file there is a config section defined like this.

<section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

All that needs to be changes is to change the 8 into a 9. Once you make that change all will work once again.

This will work for pretty much any version issue you run into which looks like this. It is funny because the two class names are the same. This is your signal that it is a version issue. The nice thing is that you usually just need to change an 8 into a 9.

I hope everyone is enjoying Visual Studio 2008. Have a great day!

Visual Studio 2008 and the .NET Framework 3.5 Released

In my attempt to add to the monotony, I'll say that not long ago Visual Studio 2008 was released to all of the MSDN subscribes. With the news spreading so quickly the downloads are all taking forever. Good luck! Scott Guthrie, as usual, posted some good content about this Visual Studio 2008 release. There will be some trial versions of the professional available in the not too distant future. You can also read a nice tour of all of the new features added into this new release. Scott wrote short overviews for a lot of the information and linked to more in-depth descriptions of these features. Make sure you follow those links if you're not well informed about this release.

The Visual Studio Express Editions and  the .NET Framework 3.5 runtime are currently available for download. These downloads should work better than the MSDN full version of Visual Studio. These are not multiple gigabyte files and also are probably not as popular right now.

I've been hearing complaints all day about difficulties trying to download it. I am assuming the problems result from too many users attempting to download. Good luck and enjoy some of the great new features.

Visual Studio Extensibility

While I was at DevConnections last week, I watched an interesting demo showing off Visual Studio's extensibility. In the demo the visual studio shell is being used to edit Lua script; the scripting language used by World of Warcraft for designing custom interfaces. The demo showcased Visual Studio's flexibility and captured the audience's attention pretty well.

The speaker added an interesting interface into World of Warcraft which showed images and played sounds when she killed enemies. I think it will be nice to use Visual Studio for almost any programming language. The familiar environment will make things easier. Perhaps more add-ons for Visual Studio will be available in the near future. This WoW Lua add-on is supposed to be available on CodePlex soon.

I don't play World of Warcraft, so I will be waiting to see what extensions other people will decide to make.

Public Strongly Typed Resource Generator

I recently installed an interesting custom tool. It is an Extended version of the resource generator in Visual Studio. The nicest part of this for me is that this one is public instead of internal like the default one. In order to have a centralized resource file it needs to be usable between projects in Visual Studio, but the internal class made this difficult. I could just manually update the generated code each time after using the file, but that would just be stupid.

This is a great answer to the problem I needed to solve because it allows me to keep the resource file in one spot and not have to do and weird tricks to accomplish my goals.

The article accompanying this tool is well-written and explains a bit about how to use and install it.

This little tool is easy to install. It comes with an MSI installer or the source code whichever you prefer. I'd say just go with the MSI.

Note: Make sure if you are on Vista you run it as administrator though or it will not work. Since it is an MSI file you will not see an option to run as administrator, so you will want to create a batch file to do this. In the batch file you will execute the MSI file. You will run the batch file as administrator. The following code should be in the batch file.

msiexec /i "Absolute path to the installer \ResXFileCodeGeneratorEx.msi"

That should get it installed. You then need to create a resource file and in the "Custom Tool" field of the properties window type "ResXFileCodeGeneratorEx" into the field. This will then make your new generated Strongly Typed resources a public class.

Congratulations you may now use your resource file between projects!

Visual Studio 2008 JavaScript Intellisense!

For those of you who do not read Scott Guthrie’s Blog, you really should. I know that any time I need to write JavaScript I switch out of Visual Studio, but I will not have to with Visual Studio 2008. It is supposed to have much better support for JavaScript development. Even Intellisense. For anyone interested you should check out this recent blog entry from Scott Guthrie which gives a lot of cool information about Visual Studio 2008’s JavaScript Intellisense.

I can’t wait to start using VS 2008. It has a lot of great features I plan on getting a lot of use out of.

My Team Server Headache

So yesterday I was able to spend a long time battling with team server. It seams that source controls likes to keep track of where your workspaces are itself. So on a computer I don’t normally work on, I logged in. I set up work spaces on that machine, because Team Server didn’t specify them for me. I needed to put the code in a public place, so I did. When I went back to my normal machine, I told the server I wanted to get latest. Wow was that a huge mistake.

Five to ten minutes, and a seemingly endless stream of error messages later, team server has moved half of all of my files to another location. It seems that it noticed from the other machine that I had moved my workspaces, so it tried to do the same on my work machine. All hell broke loose when it could not get all of the files moved correctly. As should be quite obvious, Visual Studio cannot build half projects.

The best part of this whole experience was the time it took to move EVERYTHING back to its original location so I could start working again. All I wanted was 1 updated file. Never going to move workspaces again…..

Perhaps someone knows of some cool trick to stop that from happening. If you do I would appreciate knowing as well. Thanks.

Visible Whitespace in Visual Studio

Something quite horrible happened to me today. While I was working on some of my code, I accidentally hit some keys while holding the control key down. Unfortunately for me I did not see the keys I hit. Well now instead of seeing whitespace there were this little dots. I figured there was some checkbox in Visual Studio’s options. I could not find it anywhere, but I did discover a cool hack. In the fonts section, I found it keeps font information for Visible Whitespace. By changing the font color to white, I wouldn’t have to see the dots anymore or so I thought. Whenever I highlighted one of the dots I could see it again.

Now with my frustration building, what can I say I hate dots, I began trying different keyboard shortcuts. I eventually found what turns on and off white space.

The Answer:    Control + E + S

Hopefully no one else must suffer through the horror that is visible white space.