I sometimes define Business Logic classes to "help" my ASPX code-behind classes. It makes the most sense to me to include them both in the code-behind file since they work together. However, I'd occasionally like to access the Business Logic classes from higher level classes defined in App_Code but they aren't automatically accessible outside of the file.
Thus, the question: it is easy to access classes defined in App_Code but how do I access classes defined elsewhere?
UPDATE: One other thing, the ASPX page class and the App_Code class are in the same namespace - that isn't the issue.
NOTE: I have taken the advice of those who have responded (thanks guys) and am refactoring to make class access easier. However, I don't think the question is actually answered yet (in the case of an ASP.NET Website project). I don't need the answer any more but, if someone could clarify what makes classes visible when they are outside of App_Code, it may well help someone else (or even me, down the road).
Make sure you place your classes in a sensible namespace.
Place 'using' keyword in code behind files you would like to access them.
Or <%@ import if you are using them in inline code.
Put the dll that contains your classes in the /bin folder.
TBH I prefer to keep the separate library project in the same solution and have project reference in the Web probject. VS handles building and placing the dll for you.
Sometimes when you create or add any file it has been create as the content file while it has to be compile file.
Please follow the process how to resolve this issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With