Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot use external references with C# Console Application

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.

like image 821
JGilmartin Avatar asked Dec 31 '10 19:12

JGilmartin


People also ask

What is unresolved external symbol error in C?

The unresolved external symbol is a linker error that indicates it cannot find the symbol or its reference during the linking process.

What kind of an error is an unresolved external reference?

Answer. Unresolved external references occur when the symbol for a function or global variable is referenced in a program, but none of the object files or libraries specified in the link step contain a definition for that symbol.

What is unresolved external symbol error?

The compiler can identify when a symbol isn't declared, but it can't tell when the symbol isn't defined. It's because the definition may be in a different source file or library. If a symbol is referred to but never defined, the linker generates an unresolved external symbol error.


2 Answers

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.

like image 137
Matthew Abbott Avatar answered Oct 09 '22 16:10

Matthew Abbott


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

like image 42
Xaqron Avatar answered Oct 09 '22 17:10

Xaqron