Search code examples
asp.netdllapp-code

DLL References doesn't work in App_Code classes


I get some troubles with a DLL reference.

I have MySql.Data.dll in my bin folder. And I added the reference of this dll to my project.

I can well use classes from this dll (like MySqlConnection, MySqlClient, etc) in aspx.cs but i cannot use it in classes from files from App_Code folder !

For all files situated in App_Code folder (my model classes) , the using MySql.Data; doesn't work. While it works in aspx.cs files.


Solution

  • As you know, there are two types of projects that you can use to create a website in Visual Studio. The App_Code folder works for Web Site projects, but since you stated that you're using a Web Application project, this is causing you problems.

    Here's some additional reading on this topic.

    In short, I recommend just creating a different (non-built-in) folder to put your random code files in. Name it something like "code", "classes", etc.