Link added but namespace not recognized

I have added a DLL to my project. The DLL contains the test.security namespace. Now test.security is not recognized. Why is this?

I use this DLL in other projects and I have no other problems.

+6
source share
7 answers

Often it depends on what is in this namespace; for example, if nothing is there, the namespace really does not exist.

It is also possible that you are missing some other dependency, which means that the compiler cannot use (until the link is added) any of the types in this namespace (for example, if the types in this namespace depend on some type from Another .dll, and you did not refer to Another.dll).

You may have specified the wrong dll version, and the version you are referencing does not have this namespace.

Perhaps the compiler is already telling you about the problem with the link, that is, it cannot use it - look at the list of errors / warnings. For example, it could be a physically missing file or a mismatch in the .NET version or a strong naming problem, which means that it cannot use the link.

+10
source

Do you use a customer profile as a project goal? Consider this scenario:

Project A -> Project Objectives. NET Framework 4.0

Project B → Project Objectives .NET Framework 4.0 Client Profile

Project A refers to project B. Namespaces in project A are not recognized in project B.

If this scenario matches, this is due to a mismatch of purpose. The client profile supports a subset of the BCL full structure. If the assembly depends on using the full structure (for example, requiring types from System.Web , etc.), then it will not be used from assenbly, which only supports the client profile.

A simple solution, change Project B to .NET Framework 4.0 (and not to the client profile).

+15
source

1. delete the link and add it again 2. Close the solution and open it. 3. Create a new solution and add all the old ones to it.

+3
source

Check the DLL version, .NET version and your host project. NET Most probably are different, and for some reason this creates problems in your particular case.

Sincerely.

+3
source

Late, but obviously, it appeared in a recent search, so this will help newcomers who land here. Here is another confirmation.

As quoted from Dummy01's comment on his answer to this question:

Pack c # project in dll or other library

"The DLL is in the project folder or in the release folder. If it looks empty, it is because your classes are defined as personal or internal. You must change the names that you need to see outside your DLL to the public."

+3
source

I also ran into this problem. In my case, I tried to remove the link, rebuild the project referenced, and then add it again, but the problem still persists.

The problem in my case was that the classes in the namespace of the target projects were not publicly available. This meant that nothing was available in this namespace, so it really did not exist.

Establishing them at the shared level solved the problem. Hope this helps someone! :)

+2
source

I had the same problem. I changed the console application to the class library in the project properties. This fixed it.

+1
source

Source: https://habr.com/ru/post/892878/


All Articles