0

I’m working with a new ASP.Net project in Visual Studio 2019. I’ve imported two files that play nicely together in another project, but not in this one.

One file lives in the root folder and references a class that’s defined in another file, one that lives in a subfolder off of the root, App_Code. The problem is in the file off of the root – the reference to that other class has a red line under it. It says, “The name ‘blah-blah’ does not exist in the current context.” It’s not picking up the class defined in the App_Code folder.

Neither file has any namespace declared – they both just define their respective classes… Again, these two files play nicely in an older project, but not in this new one.

Any thoughts? Thanks for the help!

  • 1
    File directory structure doesn't matter for accessibility purposes. What matters is project structure (which often mimcs directory structure but not necessarily so), the project dependency graph, access modifiers, and to a lesser degree namespaces. This question cannot be answered without showcasing the project structure including dependency graph. – Flater Jun 03 '21 at 11:59
  • https://stackoverflow.com/questions/9178985/type-or-namespace-could-not-be-found-from-app-code-folder – Wiktor Zychla Jun 03 '21 at 12:00
  • as said by @Flater we'd need to see your project structure. – AsPas Jun 03 '21 at 12:07
  • Have you included them both in to the project structure? – Murray Foxcroft Jun 03 '21 at 12:10
  • That link from Wiktor did the trick. I changed the Build Action for the file in App_Code from content to compile.... – curtisdehaven Jun 03 '21 at 14:58

1 Answers1

0

You might have space in folder name, that causes Visual Studio not to find the referenced file.

kzendra
  • 31
  • 1
  • 5