May 6, 2011

Coding Practice : Always refresh the 2nd Visual Studio Solution :).

I had a problem with some code in a Visual Studio, the errors were something like when you have a missing file, or a missing method or stuff like that.

They were happening all the time and I was wondering what is going on.

The problem was that I was having 2 Visual Studio instances running with different solutions loaded in them, I was coding in the first solution and touched a shared project (.csproj).

The second Visual Studio asked me to refresh. I answered no and the old code was in the Visual Studio #2.

To overcome this, you may:

1. Always answer “Yes” to the refresh dialog (bad practice) as you may forget sometimes or accidentally click “No”.

2. Click refresh on the solution file in the second visual studio (bad solution, it is a bit slow and you may forget to do this).

3. Go to Options –> Environment –> Documents –> and check the following checkboxes:

   3.1. Detect when file is changed outside the environment (check).

   3.2. Auto-load changes, if saved : (check)

I will go with approach #3 and see if it has some shortcomings as I can’t think any right now.

A screenshot bellow shows the exact settings:

image

No comments: