DarksideCookie

Come to the dark side...we have cookies!

Weird bug/feature in Visual Studio 2010

As I was working with some of my demo code for the Azure posts I have been putting up lately, I came across a very odd thing. I had a solution with several projects that built and worked perfectly fine. I did however need to make some changes to the solution before zipping it up and putting it on my blog. So I made a copy of the solution folder, removed my source control bindings and everything else that shouldn’t be in the zip.

Before zipping it up, I thought I would just make sure it built ok after my changes, which it obviously should as I made no code changes. So I loaded the solution into Visual Studio and everything looked fine. But pressing Ctrl+Shift+B made Visual Studio cough and tell me that XXX was not available in namespace YYY, which is really odd as I had made no code changes.

I pulled out the file that complained, and started going through all the normal things. I checked that I still had a reference to the other project, which I had. I checked that the code looked ok (you know the developer thing where we pull up a file we think is fine to begin with, stare at it for a little while, and come to the conclusion that we were right that it was fine). I even made sure that Intellisense worked. If that works, everything is fine, we know that from years of using it. The code can even be right when it doesn’t work, but if it works, the coding is freaking correct.

I tried aliasing some of the namespaces to see if that made any change, it didn’t. Ok, Google to the rescue. Luckily, after just a short amount of Googling (Googling? I guess that’s an ok verb now), I found this blog post: http://www.gitshah.com/2011/06/visual-studio-2010-fixing-referenced.html.

If you don’t feel like reading it, I can explain the part of it that solved my problem…

If you have a solution with multiple projects, and references between the projects, you might end up with a cool bug. If the length of the path to the referencing project’s project folder combined with the length of the relative path to the referenced project’s project folder ends up being 259 characters, your solution won’t build. 259 apparently coming from MAX_PATH – 1.

Ok, let’s recap that… First you take the path to the referencing project’s project folder, and take the length that path. Then you get the relative path from that project folder to the referenced project’s project folder, and take the length of that path. Then you take those two numbers and add them up. If you get the number 259, your solution won’t build properly!

Ok, this is a freaking odd thing to end up with, I know! But it does apparently happen, and thanks to Deep Shah, we now know that it can happen. Luckily, it is a breeze to fix! Just move the solution…that’s all there is to it…

Even though I am sure that this post will help very few people, I still decided to post it as I think it is funny!

The next post up here will be about the Azure Service Bus, but I am currently a little busy and have limited time left over. But stay tuned!

Cheers!

Posted: Oct 13 2011, 20:57 by ZeroKoll | Comments (0) |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Manage post: :)
Comments are closed