Drag-and-Drop Not working When Debugging in Visual Studio Under Windows Vista

Tuesday, October 30, 2007

There are many programmers out there working on real-world applications who have not programmed drag-and-drop functionality. However, sooner or later, you will need this nice feature of Windows (and GUI in general).

Adding drag-and-drop support to your application is not difficult in C#/.NET. However, when it comes to debugging drag-and-drop under Windows Vista that's when trouble begins. If drag-and-drop does work fine when you run the application from Explorer but does not when you run from Visual Studio 2005 don't be surprised. We will demystify this quickly. However, I must admit that it took me about and hour to figure out what was wrong.

As you are well aware, under Windows Vista, we usually work from a low privilege account. However, because this causes some problems when working in Visual Studio, most of the programmers run Visual Studio with Administrator privileges. It turns out that Windows Vista does not allow drag-and-drop operation if you are dragging from a lower privilege application to one with administrator privileges. So now it's easy to explain the strange behaviour.

When you start the application in a debug mode, Visual Studio has administrator privileges and if you try to drag-and-drop say from your desktop (which most likely has low privileges) the operation fails. Visual Studio would not even fire the drag-and-drop events.

So, what do we do when we need to run Visual Studio under administrator privileges and yet be able to debug drag-and-drop? Well, now when we have demystified the strange behaviour, we can solve this problem. This is how I solved this. I use Total Commander as my File Manager. So I run both Total Commander and Visual Studio with administrator privileges and drag-and-drop debugging works just fine.

Happy programming!

More cool posts coming soon.

Connecting SQL Server Management Studio to a Non-standard TCP/IP Port

Saturday, October 27, 2007

Microsoft SQL Server listens for incoming connections on a particular port. The default port for SQL Server is 1433. However, it doesn't need to be 1433.

It is a bit tricky to connect to the SQL Server running on a non-standard port. When connecting to the SQL Server running on a non-standard port, many people instinctively try to specify the server address in a IP:PORT format. Unfortunately, this doesn't work.

In order to connect to an SQL Server running on a non-standard port, you must specify the server address in a IP,PORT format. For example, if the IP address of the server is 235.12.175.96 and the SQL Server listens to 1037 port, you must specify 235.12.175.96,1037 as the server name.

A Few Words on the Coding Style

Friday, October 26, 2007

When developing software, it is important to adopt a good and consistent coding style. It doesn't matter to a computer what coding style you use or if you use any at all. However it does matter to other people reading your code. Even if you work on a project alone and the chances of other people reading your code are pretty slim, it still makes sense to use a clean coding style. Experienced programmers know that after a couple of weeks, even own written code becomes difficult to understand if it is written poorly.

When it comes to a coding style, my opinion is that any coding style that makes sense to you is okay as long as you stick to it. Inconsistent coding style is a terrible thing and shall be avoided at all cost.

CSharpFriends.com has a . I use the same style with only few exceptions. So, I highly recommend that you read that document. It is a bit lengthy, but will help you quickly grasp my code and the time you will invest in reading it, will pay off quickly.

Welcome to en.rammstein-europe.com

Wednesday, October 24, 2007

Thank you for visiting en.rammstein-europe.com. As you may have already guessed from the name of the blog, en.rammstein-europe.com will be dedicated to software development. Unlike many other blogs and web sites, our focus will be real-world, complex, enterprise scale applications. I will try to uncover topics not taught in most of the books about computer programming. On en.rammstein-europe.com you won't find such examples as Dog inherits from Animal. Everybody can teach Object-Oriented Programming on simple examples. However, when it comes to large, complex, distributed applications, the task becomes daunting.

Search Amazon.com. The world's largest online shop lists thousands of computer programming books but hardly will you find a descent book about building real-world applications. Of course, there are a couple of great books out there, but one cannot cover everything in a book or two. However, on a blog, I'm free to post and deliver material as we progress.

To sum up, en.rammstein-europe.com will touch advanced topics of software development and will be most interesting to "intermediate" programmers who are just starting working on large-scale, applications. Our main focus will be Web applications, however many of the concepts will be applicable to non-web applications as well. Microsoft .NET 2.0 will be the primary platform. All of the samples will be in C#.