Ben
Ben

Reputation: 669

File in ASP.NET app_code cannot see referenced file that was added to the web application

The issue I'm having is that I have a class file in app_code that does not see a reference added to the web app. I added the reference file to the project (IBM.Data.Informix specifically) and an aspx.cs page in the project folder does fine with "using IBM.Data.Informix". When I add the using statement to the class file, however, it cannot find it.

There are MANY questions in regards to how to access the class files within app_code, but I've been unable to find anything in regards to this. I'm using VS2012, if that makes a difference.

There error is exactly what you'd expect to get when trying to use an unreferenced file, even though the reference works in the aspx.cs files in the project folder:

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0246: The type or namespace name 'IBM' could not be found (are you missing a using directive or an assembly reference?)

Source Error:
Line 7:  using System.Net.Mail;
Line 8:  using System.Text;
Line 9:  using IBM.Data.Informix;

Upvotes: 3

Views: 2143

Answers (1)

Ben
Ben

Reputation: 669

This issue, pointed out by Jason P, was that I was using the App_Code folder and that's apparently intended for web sites, not web apps like this one, and the code within the folder cannot access references.

Seems odd, but moving the class file to the main folder resolved the issue.

Upvotes: 3

Related Questions