A small issue I ran into yesterday was about getting NHibernate to run inside an ASP.NET “Website project” without using any external assemblies to store my domain objects and their mapping files.

The underlying problem is that those “Website projects” are stored as simply editable code files and are dynamically recompiled by the ASP.NET process on the web server, instead of being pre-compiled and then deployed as in a “Web application project”. This may or may not be easier to work with, depending on your project. Anyhow, it is your only choice if you're using Visual Studio Web Developer Express like me. Now, since ASP.NET is recompiling your code automatically, you have no means to include your NHibernate mapping files (*.hbm.xml) as embedded resources. Moreover, you won't be able to refer to the assembly built by ASP.NET (which contains your domain classes), because the assembly name will be generated more or less randomly.

A possible solution to this problem is to simply put your domain classes, and their mapping files, into a separate assembly, compile it and then add it as a reference to the website. This however is a clunky process: it requires you to use another instance of Visual Studio (in its Express edition) to edit the external library and you are slowed down by having to recompile and relink the parts each time. Fortunately, this blog post pointed me to an easier and more elegant solution.

More...