Reputation: 11
I have a dll from a class library project AppconClient. I am referring that dll in another class library project p2. I copied that dll from project AppconClient and copied to Bin\Debug
folder of the project p2 and I referred the dll by clicking add reference in the project p2.
I was happy to see the namespace of AppconClient when I tried to refer the dll by using
keyword at the top of Program.cs
in my project p2. And I could see the classes and methods of that dll inside my project p2. But when I tried to build the project p2 I got the error saying,
The type or namespace name 'AppconClient' could not be found (are you missing a using directive or an assembly reference?)
But the same dll can be referenced in any WebApplication and it works fine also.
Can anyone tell me what could be the reason and solution for this?
Upvotes: 0
Views: 4939
Reputation: 2971
Dont Copy. If you copy this may happen because when you are publishing your web site the Copied DLL may be missing.
Right way to do is Add Reference
and browse. VS will automatically do it for you.
Upvotes: 0
Reputation: 17724
You are not supposed to copy the file to the bin\Debug
folder.
The compiler will add all your referenced assemblies there.
You only need to add the reference to your original dll.
When you rebuild a project, dll files are deleted(this is what Clean does) and a fresh copy is placed there. Your original dll got deleted. So it was not there later to build the project.
If you cannot reference the original dll directly, make a copy in your project, probably a folder called Lib and put it there.
Upvotes: 0
Reputation: 2687
There is no need to copy it manually into bin\debug. All you supposed to do is to add reference to the library from the original folder, and in the newly added reference properties set CopyLocal value to True.
Upvotes: 3