Intellisense missing in App_Code, for bin dlls in Website Project
Asked Answered
A

2

6

Any classes I create in the /App_Code or /App_Code/[subfolder] don't have local intellisense.

That is - I have intellisense for system dlls such as string.[member] etc. But cannot get it to recogize any classes local to App_Code (including itself), or dlls referenced in the /bin folder.

Although I do have intellisense of inside the scope of a member-function. (ie. local variables or function parameters)

NB

  • This is a Web Site project, not a Web Application project.
  • I have tried resetting all the Visual Studio settings and clearing the intellisense information found in AppData for VS.
  • Im working with Visual Studio 2012 ver. 11.0.61030.00 Update 4
  • The project is using .NET 4.0
  • If I move the classes outside of the App_code folder, they register in intellisense perfectly.
  • There is no option to set the Build setting of the files to Compile as this is a web site project rather than a web app.
Accentuate answered 29/4, 2014 at 13:14 Comment(2)
Are these classes in a namespace?Setscrew
@DeadlyChambers, they aren't but I've tried adding them to one, with no success.Accentuate
F
2

IMO, you should move your code out of App_Code. In .net 4.5 (and 4.0) your behind code is compiled to a dll, so I don't see any benefits to putting your code in App_Code. If someone advises different, I am interesting in hearing.

With that said, create a folder or folders under your root project and put your code in there.

MyWebsite
 - DataLayer
     MyDataLayer.cs
Default.aspx

In this example, you will be able to access your classes DataLayer.MyDataLayer

Even better create a new library for code that is not needed in your aspx.cs code behind files.

Frigorific answered 1/5, 2014 at 14:20 Comment(1)
The code in App_code is not compiled until run-time. It will store source code instead of compiled code. But as I said, I don't see a benefit. I had the same issues as you. It was easier to create a folder and place the code in there. See here msdn.microsoft.com/en-us/library/t990ks23(v=vs.90).aspxFrigorific
T
2

New code files in App_Code will have the build action "Content", hence you got no intellisense. So right click your code file and click "Properties", in the property window change the "Build Action" to "Compile".

Then reopen your code file.

Triacid answered 2/5, 2014 at 7:13 Comment(2)
I'm using Visual studio 2012, which doesn't have this option in the properties window. Do you know where these per-file properties are usually stored for VS to read from? The solution file maybe?Accentuate
Yep I'm sry. In 2010 it was still possible. I just tested it in 2013, and there is no "Build Action" inside of the property window of the class file.Triacid

© 2022 - 2024 — McMap. All rights reserved.