开发者

Recreating a solution

I'm trying to recreate a solution that had multiple projects in it (only the cs, aspx, etc, remain). When I create a blank solution and blank project files and start re-adding things, I receive the following compiler errors numerous times:

The type or namespace name 'Activation' could not be found (are you missing a using directive or an assembly reference?)

The Activation class is defined in a Activation.cs file that is in a sub folder to the cs file that is using it. I've added and included the files in the project...

The website currently works in production as is, so I'm wondering what type of reference I need...

The following is the structure

  • Solution

    • Project1

      • FileUsingActivation.cs
      • Folder1

        • Activation.cs (which contains the class being used in FileUsingActivation.cs that the compiler is complaining about

Edit 1: Just a note that Visual Studio can't resolve the class name, meaning it currently has a squiggly line under the class1 : Activation (Acti开发者_运维百科vation portion). But the file is definately included in the project, it's just under another sub folder... I mean I know it won't compile because VS can't resolve the name, but I'm wondering why....

Edit 2: If I add the file to the root of the project, the class name highlights blue, the squiggly goes away as does the error.... so I can't keep the existing folder structure in the project for some reason????


long shot: check for compiler conditionals (like #if some_condition/.../#endif);

Your build configurations might have contained them.

Also, check that the build action is 'compile' for the build configuration that you're trying to build.

  • Build configurations: MSDN
  • Conditional Compilation: MSDN


Could be a few things, but given your context...

Are you using .NET 4/VS 2010? The default "Target Framework" for projects is .NET Framework 4 Client Profile, but if you are referencing another project that is the full .NET Framework 4 you'll get this un-informative build error.

To fix this, right-click on your project, click "Properties", and under the "Application" tab set the target framework to .NET Framework 4 (and not .NET Framework 4 Client Profile).

EDIT: For anyone else who stumbles on this question/answer, the above solution will work for you if your classes appear to be included/working while editing (highlighted light blue, etc), and you can right-click "Go-to Definition" for it, but then it gives build errors as if it could not be resolved.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜