tags:

views:

130

answers:

2

solution structure [Plain Winforms + VS 2008 Express Edition]

  • CoffeeMakerInterface (NS CoffeeMaker)
  • CoffeeMakerSoftware (NS CoffeeMakerSoftware)
  • TestCoffeeMaker (NS TestCoffeeMaker)

CoffeeMakerSoftware proj references CoffeeMakerInterface. TestCoffeeMaker proj references CoffeeMakerInterface and CoffeeMakerSoftware.

Now the thing that is driving me nuts. I can't get this to build. If I remove CoffeeMakerSoftware project reference from TestCoffeeMaker it builds (??!!).. as soon as I add the second project reference, it throws build errors claiming that types declared in first reference 'can't be found.. are you missing an assembly ref'

At first I had the first 2 assemblies having the same namespace CoffeeMaker.. I then made them distinct (although I think having classes belonging to the same NS across assemblies should be possible) but even that doesn't seem to be it.

Calling more eyeballs. Any pointers..

A: 

A few things to check:

  • Ensure "copy local" is TRUE for all project references
  • If any are set to false, check the GAC for old builds of your libraries

If all this fails, remove all projects from the solution, create a new solution and add the projects back. Yeah, it's voodoo, but this has got me past silly mistakes before. ;-)

x0n
Already tried that ;).. at midnight anything was worth a try... didnt work.
Gishu
+1  A: 

I broke my 'Don't code when you're tired' dictum. I zipped it up, went to sleep and looked at it today.. found the issue by looking at the output window. (FWIW everything was CopyLocal=True and nothing in GAC. This is Bob Martin's OOD problem from the Agile PPnP book.. coming up with good names was particularly hard)

1. CoffeeMaker > CoffeeMakerInterfaces
2. [X]         > CoffeeMaker            > CoffeeMakerSoftware
3. [X]         > TestCoffeeMaker

That's how I added and renamed the projects in chronological order. Apparently renaming the Assembly via solution explorer, doesn't change the name of the produced binary or throw up a warning. As a result, #1 and #2 both were producing CoffeeMaker.dll as the output. Adding Reference#2 to the TestCoffeeMaker rendered all the types defined in reference#1 as unknown with the ever popular

"Error 2 The type or namespace name 'CoffeeMaker' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\pillaigi\Desktop\CoffeeMaker\TestCoffeeMaker\FakeCoffeeMakerDevice.cs 4 7 TestCoffeeMaker"

Solution: Open Project properties and examine if the "Assembly name:" in project properties for each (ref or otherwise) project is unique and doesn't clash.

Maybe not enough people do this.. the IDE or compiler could easily catch this one 'If referenced assemblies have the same binary name... please fix it.. you will anyway' I've done this to myself once before.. Making a BIG note to myself this time. Now excuse me while I wear my Dunce cap and sit in the corner.

Gishu