Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I've an existing solution called Portal.sln which contains more number of projects. HLS.Common is one of the projects. I've added some .NET reference DLLs to the Common project (System.DirectoryServices and System.DirectoryServices.Protocols). I've added a public class and implemented a public method in the class.

I create another solution and refereed the HLS.Common DLL. While trying to access the newly created method I get error as given below.

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

How to resolve the issue?

My code is shown below.

C#
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.DirectoryServices; 
    using System.DirectoryServices.Protocols; 
    using System.Net; 
namespace HLS.Common.LDAP
{
    public class LDAPCommunicator
    {
        public bool VerifyLDAPConnection()
        {
            try
            {
                //Some logic here to connect with LDAP return true; 
            }
            catch (Exception e)
            { return false; }
        }
    }
}

In the client, in main method below code is used. In using statements using HLS.Common.LDAP is added.
LDAPCommunicator ldapCommunicator = new LDAPCommunicator();
bool result = ldapCommunicator.VerifyLDAPConnection();
Posted
Updated 15-Oct-12 7:07am
v2
Comments
Sushil Mate 11-Oct-12 3:34am    
Have you added the reference correctly?
Have you import the namespace in using statement?
Sergey Alexandrovich Kryukov 11-Oct-12 3:44am    
Import? Using statement has nothing to do with namespaces (it is only related to IDisposable). You mix it up with using declaration:
http://msdn.microsoft.com/en-us/library/was37tzw.aspx
It simply changes the naming, has nothing to do with assembly referenced. You first question to OP is quite correct.
--SA
Sushil Mate 11-Oct-12 4:45am    
i mean to ask in a different way.. :)
anyways thanks for correcting me..
n.podbielski 11-Oct-12 3:34am    
Can you paste your code?
Oshtri Deka 11-Oct-12 3:35am    
Have you tried to remove and add reference again?

1 solution

You're adding a reference to the .DLL directly instead of the project for that .DLL.

When you make a change to the .DLL project and recompile, your reference to this .DLL is no longer valid as it relies on the version information in the assembly.

If you add a Project reference instead of browsing to the .DLL, this problem disappears. The problem with this is that you have to add the .DLL project to the solution containing your app holding the reference.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900