9

I have tried all the suggestions below but still no joy.

I'm now trying a console application, and let me explain exactly what I'm doing.

  1. I create a new console project in VS 2010
  2. I add a number of references (dll's) some that aren't mine such as Castle.Winsor and N2 CMS dlls
  3. in the console app I can add using statements indicating I am using name spaces within the referenced DLLs
  4. I start writing code.
  5. As soon as I compile all the code that uses the referenced DLLs immediately complains with "The type or namespace name '' could not be found (are you missing a using directive or an assembly reference?)"

I have tried setting the dlls to copy to local always, I have copied the DLL into the same directory, I have tried added reference by project and adding a reference to the DLL's themselves

I don't get this problem with a web application project or a ASP.net project they always work fine, only something that is compiled to an EXE like a console app or windows service.

there must be something I'm missing or I would have got this working by now.

Cœur
  • 37,241
  • 25
  • 195
  • 267
JGilmartin
  • 8,683
  • 14
  • 66
  • 85
  • 1
    Data_objects vs Data_Objects. Being accurate is so very important when you ask a question like this. – Hans Passant Dec 31 '10 at 20:04
  • Are you using the fully qualified path to the objects where you're referencing them in code? Is there a potential naming confilict where Data_Objects exists in more than one place? Does VS give a line #, and if so, can you post the error and a few lines of code around the error as part of your question? – David Dec 31 '10 at 20:08

5 Answers5

37

Change the project Target to a non Client Profile target. Right click the Project and select Properties, you should see a list of Framework versions. As you are using VS2010, the Console project you've created by default targets .NET Framework 4.0 Client Profile, change that to .NET Framework 4.0.

Matthew Abbott
  • 60,571
  • 9
  • 104
  • 129
  • It makes sense really, Client Profile only targets a subset of the full .NET 4.0 framework, things like System.Web are omitted...so any referenced assemblies that have references to assemblies not provided by Client Profile will fail to bind. – Matthew Abbott Jan 02 '11 at 11:06
  • I find that in 99% of the cases, Client Profile doesn't have the assemblies I need. So much for compactness, eh? – Dmitri Nesteruk Jan 02 '11 at 11:15
  • Excellent, that did it :) This must have caught out more people, as there was no error message that mentioned this - A big thank you – JGilmartin Jan 02 '11 at 11:16
  • @Dmitri - I find that its mostly external libraries which have references to these other assemblies which drives me to using full .NET 4 instead of Client Profile. The only things which are not included is ASP.NET, some advanced WCF stuff and other bits and pieces. Client Profile does actually include quite a lot: http://msdn.microsoft.com/en-us/library/cc656912.aspx – Matthew Abbott Jan 02 '11 at 11:20
  • @Matthew: you're right, I guess. I find myself needing `System.Web` stuff like `HttpUtility`, which is fairly simple, but not in Client Profile, unfortunately... – Dmitri Nesteruk Jan 03 '11 at 10:54
2

Check if Copy Local is set to true for the referenced assembly.

Xaqron
  • 29,931
  • 42
  • 140
  • 205
0

First, as to your question, its hard to know exactly what you're doing wrong, but from the fact that you're using an underscore in an assembly name (and probably in namespaces and type names), it suggests you're rather new to the .NET world.

This suggests that you're adding references to other projects in your solution by browsing to the compiled assembly, rather than by adding a Project Reference. When adding a reference, you must select the Project tab rather than browsing for the assembly.

Even if you don't believe this is the issue, remove all references and re-add project references to make absolutely sure. Assumption, asses etc.

Once you've done that, I'd strongly suggest remove all the underscores from your types, namespaces and assemblies. You might want to go read the framework design guidelines, too.

0

Open your .Proj(Windows service project file) file in notepad and check whether your assembly location(data_object) is the same which you are pointing.

When you open .Proj file in notepad you can check for,

Project reference,

        <ProjectReference Include="C:\StackOverflow\StackOverflow.csproj">

And if you giving dll or exe refrence then

 <Reference Include="StackOverflow, Version=1.0.0.0, Culture=neutral,       processorArchitecture=x86">
  <SpecificVersion>False</SpecificVersion>
  <ExecutableExtension>.exe</ExecutableExtension>
  <HintPath>C:\StackOverflow\bin\Debug\StackOverflow.exe</HintPath>
</Reference>

I suggest you to give exact location including drive name like above example.

Other option you may try,

 1. Clean and rebuild
 2. Add Project reference if you already tried dll reference
 3. Check whether the folder (referred assembly location) is Read Only then remove it. 
indiPy
  • 7,844
  • 3
  • 28
  • 39
0

In VS 2019, I had two projects, one C++ and other one C# Console in one solution file. When tried to add a dll reference through "Add reference", I was not able to see Browse button in "Reference Manager" window, to select dll file.

But when I created only C# Console app inside solution then I could add dll reference.

Pabitra Dash
  • 1,461
  • 2
  • 21
  • 28