0

I'm unable to reference certain types in a separate assembly. The strange thing is that, when I browse the referenced assembly in the object model, I can see the type I'm looking for there. But when I try to reference the type, the compiler gives me "the type or namespace name cannot be found".

More strange facts:

  • I can reference another type in the same assembly and namespace
  • I can reference the missing type from another assembly (an MVC project, the project in question is a C# Windows service)

Does anyone have an idea what might be going on?

UPDATE

I just noticed that if I remove the dependency library reference, them re-add it, the type references immediately resolve. But then, when I try to build the dependent project, it again says the references cannot be found.

Here are the classes

Dependency Library Project

namespace LibProject
{
    public class HelloWorld {}
}

Dependent Project

namespace MyProject
{
    public class HelloTest
    {
        LibProject.HelloWorld test;   // Type or namespace name could not be found
    }
}

END UPDATE

McGarnagle
  • 101,349
  • 31
  • 229
  • 260
  • Please show an outline of the classes, public/private modifiers and using directives. – H H Apr 10 '12 at 21:42
  • 2
    Which framework are you targeting? I had a similar problem once where the class wasn't in the Client Profile, but it *was* in the full framework (same version number, sans "Client Profile"). – Jeff Apr 10 '12 at 21:45
  • I've had similar issues where the Visual Studio intellisense or something wasn't updating and picking up my changes. I ended up having to wipe out all the compiled DLL files in the various bin directories and restart Visual Studio for them to be picked up again. Also have a similar issue where I have the same classes but built for multiple platforms within the same solution; had to close the opened files and re-open them in context of the platform I'm currently coding in. – Chris Sinclair Apr 10 '12 at 22:02
  • @Jeff E, I think you might have it. My dependent project was targeting the Client Profile, but the library project was targeting the full framework .. – McGarnagle Apr 10 '12 at 22:07
  • @JeffE that fixed my issue, thank you. Could you add as an answer so I can accept it? – McGarnagle Apr 10 '12 at 22:11

1 Answers1

1

Which framework are you targeting? I had a similar problem once where the class wasn't in the Client Profile, but it was in the full framework (same version number, sans "Client Profile").

Jeff
  • 7,504
  • 3
  • 25
  • 34