I’ve got some code I wrote that will take a language independent output, and convert it to the desired language (e.g. English or French.) For the longest time, I used this block of code inside my main assembly. However, as functionality increased, users wanted this same information on an intranet website. This caused me to split it out into a DLL that could be accessed by both my main application as well as the web application (which was not written in .Net.)
Since this little block was in my main application, I had always used a couple config files for configuring my NHibernate Configuration objects (one for each type of server I was using.) This wasn’t a terrible deal, I just needed to make sure I included the corresponding *.cfg.xml files with the application whenever it was deployed.
Today, however, I was tasked with creating a WCF web service that mimics this functionality. I got the web service up and running, except every time it hit the .configure() statement it crashed because it couldn’t find the file. It was looking in something like C:windowssystem32inetsvrbin.… since it was running on IIS.
To get around this, I changed my DLL. Instead of using cfg.Configure(“palelocust.cfg.xml”), I now just use cfg.Configure().
I then opened up the web.config file of my new WCF test. I added this line to the config sections:
Then, further down, I added the following section:
NHibernate.Connection.DriverConnectionProviderNHibernate.Driver.SqlClientDriverfalseNHibernate.Dialect.MsSql2000Dialecttruetrue 1, false 0
Then, in my WCF project, I added a reference to the NHibernate DLL and set it to copy local.
I published my service on our internal server, ran the server using WCFTestClient (thanks MS) and everything ran fine.