Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...