3

Visual Studio 2012.

I have two projects A and B. A is the console application. The default namespace of A is "PayT'. B is class library type, the sAssembly name' is 'RetentionPolicyManager', the default namespace of B is 'RetentionPolicyManager'.

Now in project A, I added reference of B that is RetentionPolicyManager.dll to it.

In one class of A, there is one line:

using PayT.RetentionPolicyManager;

However I always got the error when I rebuild the solution:

The type or namespace name 'RetentionPolicyManager' does not exist in the namespace 'PayT'(are you missing an assembly reference?)

If I don't build the solution, it seems to be okay and no error.

D Stanley
  • 149,601
  • 11
  • 178
  • 240

5 Answers5

13

I faced same issue some months ago. The problem was both projects didn't target the same platform, i.e. the console application targeted .Net framework 4.0 Client Profile while the library targeted full .Net framework 4.0.

Fixed by targeting full .Net 4.0 framework for both projects.

ken2k
  • 48,145
  • 10
  • 116
  • 176
  • 1
    I used .net 4.0 in one project, .net 4.5 in the other project. Now I applied the same .net 4.0 to both of them. Now the library project's reference could not be found error(Metadata file could not found in B\bin\Debug, but it is there). –  Jan 21 '13 at 14:23
  • Which is 4.5, which is 4.0? Could you try specifying 4.5 for both? – ken2k Jan 21 '13 at 14:26
  • Shouldn't this be an error that VS can spot at compile-time and not throw a seemingly unrelated error? – anthonybell Aug 22 '13 at 20:13
  • 1
    I wish I could +10 this. Although it didn't solved my problem, it guided me to the source. I would have lost days just to figure that the targeting platform could provoke this. – André Santaló Apr 23 '14 at 14:43
1

That's because RetentionPolicyManager doesn't exist in PayT it is it's own namespace in a separate dll, you just need:

 using RetentionPolicyManager
James
  • 80,725
  • 18
  • 167
  • 237
0

As per your description, it should be:

using RetentionPolicyManager;

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
0

In A just use:

using RetentionPolicyManager;
Hamlet Hakobyan
  • 32,965
  • 6
  • 52
  • 68
0

the namespace of B is RetentionPolicyManager, PayT is the namespace of the Assembly A. remove PayT from using statement.

using RetentionPolicyManager;
daryal
  • 14,643
  • 4
  • 38
  • 54