@mabraham:
First of all: thanks so much for trying to help me resolve this issue. I have taken your code and changed it a little. The reason why is that the name attribute of the class node is not all that needs to be changed. However I did read that you can set a default namespace and assembly in the root node of the mapping file so I adapted it to do exactly that:
Code:
Type type = typeof(Symtech.BusinessObjects.BusinessUnit);
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
XmlDocument doc = new XmlDocument();
doc.Load(Request.PhysicalApplicationPath + "/App_Code/BusinessUnit.hbm.xml");
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("hbm", "urn:nhibernate-mapping-2.0");
XmlNode n = doc.DocumentElement;
System.Diagnostics.Debug.WriteLine("Assembly:" + type.AssemblyQualifiedName);
System.Diagnostics.Debug.WriteLine("Nr of attributes: " + n.Attributes.Count.ToString());
XmlAttribute a = n.Attributes["assembly"];
a.Value = type.AssemblyQualifiedName;
cfg.AddDocument(doc);
Mapping file:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="Symtech.BusinessObjects" assembly="">
The code seems to be altering the mapping file fine and also seems to propagate the default assembly, however it still cannot find the class even though it obviously gets assigned the fully qualified assembly name judging by the debug output and, unfortunately, the error message.
Code:
NHibernate.MappingException was unhandled by user code
Message="persistent class Symtech.BusinessObjects.BusinessUnit, Symtech.BusinessObjects.BusinessUnit, App_Code.u2gcijeu, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null not found"
Source="NHibernate"
@Dylan:
Yes, if I had VS2005 Pro at my disposal these workarounds wouldn't be neccesary as I would create separate projects (library projects) to handle said tiers. Unfortunately Web Developer will only create web projects without the option to control the resulting assembly names.
Are you sure you have your DAL and domain model residing inside the web project and not in separate projects? If so I would indeed be very interested to see how it's done!