Posts Tagged ‘Visual Studio’

Getting the ASP.NET Development Web Server to use a root path

Friday, July 10th, 2009

ASP.NET 2.0 comes with a test webserver which can be run by simply pressing F5 in Visual Studio from a website project which is located on your PC.  The only problem is that for reasons best known to Microsoft, it launches with the site configured in a subfolder.  This isn’t always convenient, as you may have paths relative to the site root which prevent this being practical for testing.

In order to get around this problem, you need to take the following steps: –

First of all, configure Visual Studio so that you can launch the test server manually as follows: –

Under the Tools menu, select External Tools.
Add a new entry
Call it something like ASP.NET Development Server
Command is C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\WebDev.WebServer.EXE (you may need to alter the path for your local machine)
Arguments are /port:80 /path:$(ProjectDir) (note that you will need to leave a space on the end of this for it to work properly.  Also, you can change the port number if you wish)

Press OK.  You can now launch the development server from the new entry on your Tools menu.  This will show in your system tray.  You should probably remember to close it when you are done.

The next step is to configure your project to use the server.  Right click on your project and click Property Pages.  If an empty dialogue comes up, press cancel and repeat the process – it should work second time.  Under Start Options, select Use custom server and leave the Base URL blank.  You may wish to change the start action as well.

Once you are done, you can press F5 to start debugging.  Don’t forget that next time you open the project you will need to start the server from the tools menu before you start debugging again, otherwise it won’t work.

Also, bear in mind that if this is a copy of a remote site, things like database connection strings may need changing.  Don’t forget to be careful not to overwrite any settings when you copy back if that is the case!

If you do want to develop on a copy of the site, the Website menu has a useful option to Copy website.

FrontPage Server Extensions in Windows 2008

Friday, July 10th, 2009

As I mentioned in a previous post, I am currently in the process of switching to a One and One dedicated Windows 2008 x64 Server.   I was trying to work out how to set up FrontPage Server Extensions, which I’m not a big fan of, but I do find them very useful for editing remote sites directly through Visual Studio and my life would be a lot more difficult without them.  The problem is, I couldn’t find any reference to FrontPage Server Extensions anywhere in IIS7.

After a bit of research, I found that Microsoft no longer support FrontPage Server Extensions in Windows Server 2008 as they have replaced it with WebDAV, which seems technically much better.  The problem is that WebDAV isn’t supported directly by Visual Studio (please sort that out Microsoft!), so the only way of using that is to use WebDAV Redirector so that you can map a network drive for the folder and then access the network drive from Visual Studio.  This is not really a practical solution for me as I would have dozens of sites to keep track of and I don’t have the patience to remap them when I need them or keep track of so many different drive letters!

A quick hunt around online for an alternateive gave me Ready to Run Software’s site, which frankly looks suprisingly unprofessional if you believe that they are actually working with Microsoft.  I don’t know whether they are or not, but they do seem to be the sole supplier of a ported version of FrontPage Server Extensions for Windows Server 2008.

All credit to them, their port of it does seem to work, although I did get an error “unable to read configuration for Microsoft Internet Information service” when I tried to install it, but their FAQ deals with that.  I managed to get it working, although it is a real pain in the neck that you have to be logged in as Administrator and not just an administrator!

The problem I had was managing the FrontPage settings for the website itself – I wanted to add another user.  I couldn’t seem to log in to the site admin – it wouldn’t authenticate me whatever username I used or whoever I made the web administrator.   The only solution I found was to use owsadm.exe, which took a bit of hunting around for how to do it.

First of all, I found it in C:\Program Files (x86)\Common Files\microsoft shared\Web Server Extensions\50\bin\

Secondly, I needed to work out how to call it.  It isn’t very well documented, but you need to do something like this…

owsadm -o roleusers -c add -u username -m domainname -web /subweb -name Admin

replace username and domainname as appropriate, and /subweb with the path to the subweb that you want to add the user to.  That can just be / for the root web.  You can replace Admin if you don’t want to use the administrative role for your new user.  I’m not sure what the other role names are.

Debugging .NET Framework Source Code

Thursday, May 1st, 2008

I’ve just set up this from Shawn Burke’s blog, and it seems to work.  Should make life easier when I hit something that I can’t work out why it is failing in the .NET framework!

.NET Compilation Part 1: Profiles

Tuesday, March 18th, 2008
This entry is part of a series, .NET Compilation»

You may have noticed that in Visual Studio, most projects start off with Debug and Release profiles. This is used to control the way that the code is compiled.  By default, Debug mode creates a pdb file and compiles the code to allow it to be used.  A pdb file contains information which will help you debug the program, such as information about how the source code maps to the compiled code.  This means that eg. when you get an Exception, the StackTrace property will give you information including line numbers.

On the other hand, a Release profile is much more optimised, both in terms of file size and code speed.  However, it is entirely up to you whether you ship a Debug application.  I wouldn’t recommend it for a large number of users, but for a constantly changing application in a small office, full stack traces with line numbers can be useful to find bugs that are difficult to trace.

Checking if a Debugger is Running in .NET

Monday, March 17th, 2008

System.Diagnostics.Debugger.IsAttached will return True if a debugger is running.  Note that this is completely different to compiling in Debug mode, and you can’t use this function to test for that.  Conditional compilation is more suited (coming soon).

Here Comes the VAT

Monday, March 17th, 2008

Looks like when I wrote this, I spoke too soon.  My VAT bill has just arrived for just over £50.  I can’t complain too much though – it is still about £200 cheaper than buying it here!

SharpDevelop

Sunday, March 16th, 2008

If you find Visual Studio too expensive, and you don’t want to use the Express Editions, then there is an open source alternative called SharpDevelop.  I’ve never used it myself, but I have heard some quite good things about it.  According to the features list, as far as I can tell, they have most of the main features of Visual Studio 2005.

Multiple Visual Studio Versions on a Single PC

Sunday, March 16th, 2008

Sometimes it is useful to be able to have multiple Visual Studio installations on a single PC.  I’ve heard some worries about whether this will cause any problems.  Personally, I have had Visual Studio 6, Visual Studio .NET and Visual Studio 2003 on one PC.  I have also had Visual Studio 6, Visual Studio 2003 and Visual Studio 2005 on another, and Visual Studio 2005 and Visual Studio 2008 on a third.  None of these seemed to cause any apparent problems.

From the point of view of the frameworks, there is very little chance of causing problems…

From 1.0 to 1.1 there were some minor behaviour changes.
From 1.1-2.0-3.0-3.5  I’ve never noticed anything that breaks old code.

Each version includes previous versions.  There are also service packs for 1.1, 2.0 and 3.0 (all SP1s at time of writing). These are included in the 3.5 installer.  2.0 SP1 does include some new classes which are required for some 3.5 features and new compiler features for the 2008 compilers (such as some Linq stuff) to work, but I am pretty certain it won’t break anything.

Visual Studio Express Editions

Saturday, March 15th, 2008

For those of you who don’t know about them, Microsoft have free cut-down versions of several of the Visual Studio languages available to download.

The three main languages are available – Visual Basic Express Edition, Visual C# Express Edition, Visual C++ Express Edition. Also, for developing ASP.NET Websites and Web Services, there is Visual Web Developer Express Edition.

I find that when I am working on an ASP.NET website with some other people, whether they are designers, or just people writing/altering text, it is much easier for me if everyone uses Visual Studio or Visual Web Developer Express.

The main disadvantage of the Express editions as far as I’m concerned is that they don’t work with source control integration. That doesn’t affect individual developers, but when you are working as part of a team, it makes life difficult, especially for non-web based systems. For web based systems, as long as you are careful, it is usually ok, and Visual Studio will normally warn you if you try to save over something that someone else has changed, at least if you are using FrontPage Extensions to access the site.

Extensibility is also not supported in the Express editions, so if you need any extensions or add-ins to Visual Studio, they won’t work.

There are a number of other differences. Microsoft have a full feature comparison on their site.

Source Control and licenses.licx in Visual Studio 2005 and 2008

Friday, March 14th, 2008

One of the things that really annoys me in Visual Studio 2005 is that making even minor changes to a Windows Forms form or control will often check out the licenses.licx file, which means that someone else who is trying to make changes to another Windows Forms form or control in the same project can’t.  I have found this to be quite time consuming as I have often had to phone up the other person who is working on it and ask them to check the file in.

I have been very pleased to notice that  in Visual Studio 2008, the problem seems to have been fixed (as far as I can tell so far).  The licenses.licx file has stayed checked in for quite a while now, despite the fact that two of us are working on controls in the project.