When I add a reference to my dll in Visual Studio project, I am able to use it, but when I compile my code or try to run it, I get an are you missing a using directive or an assembly reference?_ Error. I am able to confirm that I have the right using statement for my namespace and I am able to confirm that the dll is correctly loaded. Anyone have any idea what I may not have right in this?
-
6I bet the error says something else besides that sentence. Care to show it in its entirety? And maybe some code as well? Psychic debugging is not easy, you know. Also what language are you using? C# or VB.NET? – R. Martinho Fernandes Dec 22 '10 at 18:06
-
Can you give us a little more detail? Is the related line a using statement from your dll? – CodingGorilla Dec 22 '10 at 18:07
-
Hard to say without seeing the code and the project references. Visual Studio should give you and indication of which types you're using that can't be resolved at compile time (via the squiggly lines in the code editor). – lesscode Dec 22 '10 at 18:07
-
2I had received the same error. I just set that particular reference's Copy Local property to true and the error went away. Give it a try – Omkar Dec 22 '10 at 18:07
-
3@Martinho Fernandes, I disagree. This is the symptom of compiling a project for a *client profile* framework while referencing a non-client profile 3rd party dll. It's the only error you get. Usually code completion will work fine until you compile the first time, just as the OP explains. You can then remove the reference to the dll, add it again, and the built-in VS syntax checker will not complain until you hit ctrl+shift+b. – Klaus Byskov Pedersen Dec 22 '10 at 18:16
-
@Klaus: oh, that's sad. I never run into that problem, but would expect at the very least a somewhat more helpful error message. Nothing but "are you missing a using directive or an assembly reference?" is really bad. Are you sure it isn't "The type or namespace name 'Foo' could not be found (are you missing a using directive or an assembly reference?)" – R. Martinho Fernandes Dec 22 '10 at 18:23
-
1@Martinho, with regards to the exact wording of the text you might be right. Bet the text "I am able to use it, but when I compile..." made me think this was the problem right away. – Klaus Byskov Pedersen Dec 22 '10 at 18:29
-
The message is the typical missing assembly message. There is really nothing out of the ordinary about my class library project which is where the dll comes from. I do have COPY LOCAL set to true, false did not work. – user272671 Dec 23 '10 at 05:27
-
@Klaus, can you please explain what you mean a bit more? The 3rd party dll in this case is the Dynamic language runtime from http://dlr.codeplex.com/releases/view/21425 – user272671 Dec 23 '10 at 05:42
9 Answers
Go to project settings and make sure that you are not compiling the project for a .net version that includes the text "client profile".

- 117,245
- 29
- 183
- 222
-
3I am sure it is not compiling for the client profile. That was one of the things I made sure of when I noticed the problem. It is compiled for .Net 4.0 Framework. And I did check to be sure the Dynamic runtime library dll was also compiled for .NET 4.0. – user272671 Dec 23 '10 at 05:45
-
12How can the comment say this is not the solution, yet this is the accepted solution? – Boris Callens Mar 15 '13 at 10:04
-
1In C# project the framework option can be found in project properties --> Application --> Target Framework. In VB.Net it can be found in project properties --> Compile --> Advanced Compile Options --> Target Framework – Dipendu Paul Mar 26 '15 at 11:09
-
I also have the problem. I added the dll reference in solution top node. And I can access to the class by F12. but when building, i got the error. you mentioned the way. but I am not sure how to do. Could you lead me in detail? – Jin Hong Apr 06 '16 at 16:25
-
@JinHong You need to go to the properties window of your project and change the .net version to one that does not include the text "client profile". Right click the project in question and choose "Properties". Now click the "Application" tab. Change the "Target framework" accordingly. – Klaus Byskov Pedersen Apr 07 '16 at 09:48
-
Guidance: 1) assembly loaded?, 2) assembly loaded matches with origin assembly?, 3) "using" directives pointing to old or none valid references?, 4) .csproj manifest includes source invalid?, 5) a search tool looking regex in the entire solution (every class library and project). 5) check project settings for net framework version build option (collaborate in teams bring on this kind of problen, you must agree net framew. build version in both sides) 6) After that clean and build each by separate and finally, include all references to the destination project/class library. I should work! – Felix Aballi May 26 '16 at 14:49
I had just had an issue precisely like this, even if this is an old question thought I would add my 2c on what fixed it as none of the other answers helped:
For whatever reason, when I built the solution top to bottom a certain dll was not getting updated and output that held changed code. So while my solution had no visible errors, when you attempted to build, it was still referencing the old dll and started complaining.
It was simply a case of directly re-building the offending project and after that it picked up the latest dll and built happily.
This seemed to be a freak accident as no configuration had changed between when it worked / when it didn't.

- 61
- 1
- 1
-
1Thank you. This is one of those rare cases where the exact problem I'm having right now happens finds the exactly right solution somewhere on a year-old internet post. Have a nice day! – Lincoln Bergeson Apr 03 '14 at 22:53
Sometimes, JUST REBUILD THE SOLUTION.

- 3,734
- 3
- 26
- 29
-
1This one solves my problem, soooooooooo frustrating. Anyway... thank you so much :) – hina10531 Apr 17 '16 at 23:55
The location of the DLL is important.
If you add a reference on your local machine to a DLL that is outside of your Visual Studio solution, it isn't necessarily copied into your solution files (depends on the type of solution/project).
If this is your problem, then you need to either put the DLL in the same path on the other machine, or copy it into your solution so it gets deployed along with the solution files, and change the reference.
You can also handle this with build instructions, but that might be beyond your aspirations at the moment.

- 32,337
- 7
- 60
- 92
-
The problem is the dll is referenced in the project and I am able to browse the dll via object browser in the project. The error message is just the simple error message I have above -The type or namespace name 'WorldBusiness' could not be found (are you missing a using directive or an assembly reference?) – user272671 Dec 23 '10 at 05:47
Most likely your dll is referencing another dll that the client project is not referencing and your dll code is exposing a type or an interface from the 3rd dll to the client code.
If you post the exaCt message, we'll be able to help better.

- 74,861
- 18
- 132
- 169
-
The message I posted is the exact message. Do I need to add the 3rd dll to client code for this to work? – user272671 Dec 23 '10 at 05:33
-
Are you using .net 4.0?
If yes, this dll is probably not compatible with .net 4.0

- 401
- 2
- 9
-
The class library references a the dynamic runtime library dll I get from compiling the download at http://dlr.codeplex.com/releases/view/21425 – user272671 Dec 23 '10 at 05:43
-
I had a problem like this one from an unmanaged dll. I got the same error - referenced it without problems, made the using statement and then, after running it got same message that you showed here. I was able to make it work after downgrading project to .net 3.5 – Rod Dec 23 '10 at 12:53
In my case, the main project (WinForm) was configured Framework Target: FW 4.0 "client profile". I change to FW 4.0 and work perfect!!. At first time i was looking in the referenced projects and they were ok, but de main project doesn't. I hope this help. Thank you.

- 11
- 1
In my case this compilation error has gone after adding the reference to Microsoft BCL Build Components via "Manage NuGet packages" context menu on problem project.
Before: I had project Main (console application) referencing project A (class library). Project A had dependency on Microsoft BCL Build Components.
After: I started refactoring where I picked out several classes to the separate project New. It also depended on A. But the compilation error occurred on project New as if there was no reference New -> A (although Visual Studio didn't highlight allegedly not found interfaces and classes listed in the error list of compilation).
So I checked project A's dependencies and found there Microsoft BCL Build Components. After adding it to New's dependencies everything worked fine. The most interesting thing is that Main did not contain this dependency and it didn't need it.
Hope this helps.

- 1,897
- 2
- 19
- 26