[c#] Referenced Project gets "lost" at Compile Time

I have a C# solution with two projects: a service (the main project) and a logger. The service uses classes from the logger. I've added a Reference to the logger project within the service project. At design time, autocomplete works fine: the logger's classes are visible, references that I use are colored appropriately.

I Rebuild the solution, and things go wrong. The references are no longer recognized: "The name 'Logging' does not exist in the current context' and the classes no longer exist in autocomplete. Removing and reattaching the reference gets me back to the base state of having the identifiers visible to autocomplete.

I've rebooted, cleared all caches, made sure this is the only instance of VS 2010 running on my machine.

Is there something obvious (obviously) that I'm missing?

This question is related to c# reference project

The answer is


Check your build types of each project under project properties - I bet one or the other will be set to build against .NET XX - Client Profile.

With inconsistent versions, specifically with one being Client Profile and the other not, then it works at design time but fails at compile time. A real gotcha.

There is something funny going on in Visual Studio 2010 for me, which keeps setting projects seemingly randomly to Client Profile, sometimes when I create a project, and sometimes a few days later. Probably some keyboard shortcut I'm accidentally hitting...


Make sure that both projects have same target framework version here: right click on project -> properties -> application (tab) -> target framework

Also, make sure that the project "logger" (which you want to include in the main project) has the output type "Class Library" in: right click on project -> properties -> application (tab) -> output type

Finally, Rebuild the solution.


Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to reference

Method Call Chaining; returning a pointer vs a reference? When to create variables (memory management) Reference to non-static member function must be called Cannot find reference 'xxx' in __init__.py - Python / Pycharm c++ "Incomplete type not allowed" error accessing class reference information (Circular dependency with forward declaration) C++ initial value of reference to non-const must be an lvalue Dependent DLL is not getting copied to the build output folder in Visual Studio How to write to error log file in PHP How to reference Microsoft.Office.Interop.Excel dll? Linker Error C++ "undefined reference "

Examples related to project

How to create a Java / Maven project that works in Visual Studio Code? IntelliJ does not show 'Class' when we right click and select 'New' error C2220: warning treated as error - no 'object' file generated Android Studio: Default project directory Error: Selection does not contain a main type How to open an existing project in Eclipse? The project was not built since its build path is incomplete Eclipse projects not showing up after placing project files in workspace/projects Method to find string inside of the text file. Then getting the following lines up to a certain limit "Sources directory is already netbeans project" error when opening a project from existing sources