Deployment: NHibernate XML serializer assembly
I have a C# 3.5 application that is using Fluent NHibernate 1.1 which runs perfectly on a development machine. As the application starts, in the output window I can see a number of dynamically generated assemblies loaded to support the XmlSerializer. When this application is deployed to a production environment however the fusion log indicates that there is a missing assembly: NHibernate.XmlSerializers.dll. Assigning an event handler to the AssemblyResolve event on the AppDomain instance, I see the call stack for this assembly load originating in the configuration of Fluent, which calls methods in the NHibernate assembly which in turn requires the deserialization of an XML persisted object. I was under the impression that using Fluent eliminated the need for XML configuration files so why would the library still be attempting to load such configuration file?
I've tried a number of things to resolve this including (1) using sgen.exe to precompile the missing library however this results in type errors and/or strong name issues, (2) manually creating an assembly that contains the required classes (which can be obtained by changing the XML serialization diagnostics settings in the app.config) however this results in a public key mismatch between the assemblies, presumably because NHibernate.dll has a strong name and the new assembly doesn't (or won't have one that matches the one that is referenced) and finally (3) obtaining the dynamically compiled assembly (again using the XML serialization diagnostics settings) and manually referencing it. Unfortunately the last attempt is the only one that might work (I still have to verify it) however I'm unable to give the assembly a more descriptive name (you can't just rename an assembly) so I will have to reference one called something like "eu3fm4nx.dll" which is most certainly not ideal.
The bottom line is: how do you actually deploy Fluent NHibernate without running into these XmlSerializer issues?