Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Project Dependency and Add Reference to Project still causes "The type or namespace name could not be found"

I have a solution in Visual Studio 2010 containing 6 projects (1 web application, 4 c# class libraries, 1 c# console application).

The console application is my test harness and use this to test external web services, output from methods from within my other libraries and general experimentation. This test console application has only one dependency on another project dependency, one of the C# libraries.

The referenced C# library is pretty simple:

namespace GowallaAPI
{
    public class Gowalla
    {
       private static readonly ILog log = LogManager.GetLogger(typeof(Gowalla));
       public SpotsInRadius GetGowallaSpotsInRadius(decimal lat, decimal lon, int radius) {
           //snip
       }
       //other methods removed for brevity//
    }
}

I have added to my console application a project reference:

enter image description here

And I've also right-clicked on References and selected Add Reference...

you can see the Gowalla reference already exists in this example picture

Then, I've gone to my console application and added;

using Gowalla;

Then hit build. I get this:

The type or namespace name 'Gowalla' could not be found (are you missing a using directive or an assembly reference?)

I am completely baffled. I have:

  1. Remove the dependencies completely (and then rebuilt with Gowalla references removed), and added them again.
  2. I have removed the dependencies completely (like #1) and then added them as assemblies only (Add Reference...).
  3. Checked that the target framework for both console application and class library is .NET 4.0 - they are.
  4. Checked that all necessary items within the Gowalla class library are marked as Compile in the Build property.
  5. Jiggled the build order of the project so that I am at least building the console application AFTER the library is built.
  6. Done some shouting and swearing.
  7. Given up and then returned.
  8. Moved the Gowalla C# library out to its own project entirely and then referenced the assembly (like in 2).
  9. Playing the having a constructor in Gowalla and not:

    public Gowalla() {

    } ... and nothing has worked!

Can anyone see something obvious? Am I being utterly stupid? I have been on this for hours and I wonder quietly if this is a classic 'wood for the trees' moment...

Help appreciated.

EDIT 1: This is the Gowalla.dll exposed from Reflector:

enter image description here

ANSWER: After @gov's helpful suggestion to remove the GowallaAPI library and try and add something else I did that and started adding in the old code from the GowallaAPI library. Everything worked until I added:

private static readonly ILog log = LogManager.GetLogger(typeof(Gowalla));

log4net for some utterly bizarre reason kept throwing the build. Alas, after removing the line (the reference to log4net remains), the project built and worked perfectly thereafter. Thank you to @gov for setting me on the right path! :D

like image 474
dooburt Avatar asked Aug 31 '25 10:08

dooburt


1 Answers

I had the exact same problem with log4net and it was resolved after changing target framework of the hosting project from ".NET Framework 4.0 Client Profile" to ".NET Framework 4.0"

like image 101
razi Avatar answered Sep 02 '25 23:09

razi