7

After lot's of effort and searching, I have decided to ask the question. I have a dll which I have added in my project and after adding namespace it shows error i.e.,

Error 1 A using namespace directive can only be applied to namespaces; 'Captcha' is a type not a namespace

enter image description here

When I have added this dll to other project it works fine but don't know what's happening in this project. I have cleaned the solution, added the dll and reference again but still the same error.

Edit:- ddl

enter image description here

After removing the dll I have typed cap but Intellisense shows nothing regarding captcha. enter image description here

37
  • Are you using same version of VS in both the cases? Commented Aug 19, 2015 at 5:10
  • Yes, both have same version Commented Aug 19, 2015 at 5:10
  • What happens if you remove the dll and use Captcha. What I'm getting at is; maybe there's another definition of Captcha that's conflicting? Commented Aug 19, 2015 at 5:11
  • 3
    just becasue the dll name is captcha doesn't mean it's namespace is the same, use object browser, or type global:: so intelisense show all available namespaces to you, and nice you put DLL there, but did you made a reference to it? Commented Aug 19, 2015 at 5:33
  • 2
    @deadManN if it's namespace isn't captcha that how come it shows it's classes. Please see the image and I already mentioned about adding the reference. Well it's namespace is captcha. I will attach image regarding this. Commented Aug 19, 2015 at 5:40

1 Answer 1

1

even after reading the comments, I'm pretty sure that you have a type called Captcha hiding somewhere.

You could try the object explorer, or checking inside the other dlls you have referenced (the fact that Captcha.dll works for other projects could hint you about which dll to check first).

But the message VS is giving you is pretty clear: you DO HAVE a type Captcha somewhere. I found that this is a case in which Intellisense keeps working even if the compiler is complaining.

I hope to put you in the right track.

Good luck!

Edit: just to clarify. A type can be a class, a struct or an enum.

Edit2: I just noticed you have the bin folder included in your project. Well, that is usually a really bad idea. The bin folder should be excluded from the project (right click, then "Exclude folder from project"). Then you should check your references. Just to be sure, remove all of them, and clean empty the bin folder too. Then reference the dlls through nuget or browsing to a lib folder. If you have files in the bin folder, "bad things do happen".

Sign up to request clarification or add additional context in comments.

3 Comments

I have removed the captcha.dll and then try to type captcha but Intellisense shows nothing regarding captcha. Please see the image I have just uploaded.
It doesn't matter. Try to use the object explorer and find if some other Captcha class or something exists in your other dlls. Or, type Captcha and then press <ctrl+.> . If there is a Captcha type, it should show up as an "include corresponding namespace" message.
Oh, and do the "remove and add" references I described in my second edit. The bin folder can really mess up your references.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.