I have an ASP.NET application which I also want to use as a class library. (It's a Castle Windsor application with .svc files that use Windsor's WCF facility, but it would be the same situation with any other web application with ASPX pages and some other public classes.)
I actually wanted to use the "class library" or "WCF library" project template as this allows me to choose separate debug and release folders, etc. But that wouldn't let me add a Global.asax file.
So I switched to the "web application" template, which is OK. However, if I configure separate debug and release folders, the web application won't run.
It looks like web applications require the assemblies to reside directly in the "bin" directory, not in "bin\debug".
Is there a way to achieve both, i.e. separate build folders and debugging support in Visual Studio?
I wouldn't mind setting up a local web application in IIS, so it doesn't have to be the Integrated Web Server.
To use Visual Studio to debug a deployed application, you must attach to the ASP.NET worker process and make sure that the debugger has access to symbols for the application. You must also locate and open the source files for the application.
To start debugging, select IIS Express (<Browser name>) or Local IIS (<Browser name>) in the toolbar, select Start Debugging from the Debug menu, or press F5. The debugger pauses at the breakpoints. If the debugger can't hit the breakpoints, see Troubleshoot debugging.
As you've discovered, it seems you can't do this, ASP.NET websites are hardcoded to run from the \bin
directory. You can change the output folder in the project properties and redirect assembly bindings, but you'll still end up with missing DLLs.
Looking at the stack trace for a failed load, the runtime only looks to:
$(ProjectDir)\bin\assembly.dll
and $(ProjectDir)\bin\assembly\assembly.dll
.
It has no interest in \bin\Debug
or \bin\Release
folders and they will be ignored.
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