Add Web Reference instead of Service Reference in Visual Studio 2008

I’m just in the middle turning a 2-tier app into a 3-tier app (it was planned all along, so it’s been quite easy so gar). Anyway I added the service reference to my client project and wanted to reuse shared assemblies (which was a pain in the a** in ASP.net 2.0 Webservice – let me just say I had my set of batch scripts altering the generated proxy code). But in Windows Communication Foundation it’s really easy. When you add a reference just click on the ‘Advanced’ button and choose the options.

But that’s not actually what I wanted to blog about. Even with Visual Studio 2008 and .net 3.5 (3.0) I prefer to use old style Webservices sometimes but at the same time of course I don’t want to miss out on Linq etc. Until now I kept changing the target plattform to .net 2.0 to get my ‘Add Web Reference’ context menu item and then changing it back to .net 3.5. It works, but I kept grumbling why on earth they removed the option in VS08, well it turns out they didn’t remove it, the just moved it.

In the advanced dialog at the bottom you can add a web reference as before. (But it is still counter intuitive, why is adding an old style reference a suboption after picking a service reference? I would have preferred my context menu item.)

About these ads

Visual Studio 2008 – "Ah" #1 – Automatic Properties and Object Initializers

I downloaded VS08 on Monday but didn’t really get round to doing anything until today. So far so good, looks nice. Installation was a bit long, but completed without any problems.

I just tried creating a class with some properties. Nothing really interesting, except that I’m used to using the “prop” snippet.

Well guess what Visual Studio generated when I did my usual prop + tab + tab?

public string User { get; set; }

I immediately screamed BUG, but I then came across this article by Daniel Moth. And then I remembered what this was. It’s a new feature called “Automatic Properties”. This reminds me that know I can actually start using all those features that all those slides at Tech-Ed this and last year were talking about.

I’m not sure if I’m going to like these automatic properties. It doesn’t really speed up my typing because the old prop template was just one word more, and I wonder it that one word was the cost for the flexibility of a full property template (think validation in the setters). I mean now I actually have to insert the brackets and new lines into the property myself. Well, time will tell. I’ll just start using what VS gives me (by the way, you can change those snippets if you want to using VĂ­sual Studio options).

Another feature I’m going to force myself to start getting used to is Object Initializers. This wil certainly clean up some of my code. 

User _u = new User(){ Name="Alex", Age=24 };

instead of 

User _u = User();
_u.Name = Alex;
_u.Age = 24;

(and it works nested aswell!)

Read Bard de Smet’s post about this here.