Last Friday and this morning I had been trying to deploy the latest changes to my WCF application. As I started doing this the manual way (e.g. copying all DLLs, configs, and service endpoints into a directory to zip and send up to my web server), I took a step back and realized I needed a NAnt build target because I’m going to be doing this over-and-over again. However, after creating the build target and deploying the resulting Zip to my web server, I received a strange error message when trying to invoke my services.
The specific error message can be seen below. In a nutshell, rather than relying on the standard WCF ServiceHost to invoke my service contracts, I have custom defined a factory (dubbed
MyServiceHostFactory) for building out my ServiceHost. However, WCF was unable to find the factory. I checked the bin/ directory and the assembly was present (
Coa.Accounts.Services.Host.dll). I spent a good deal of time trying to figure out why this error message was being caused. The various recommendations from Google didn’t work, and recompiling half a dozen times also didn’t fix the problem.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
This is when I tried using my setup project and noticed something interesting. Although I was copying the same files to the
bin/ directory as the Setup project in Visual Studio was, the Setup project would work and not throw the error message. This is when I started paying attention to my build process. It should compile all *.cs files in my project directory. This is where the discrepancy showed up:
1 2 3 4 5 6 7
There are a lot more than just 2 files in my project folder. There’s actually 6 files, plus 1 commonly linked file (
GlobalAssemblyInfo.cs). Sure enough, when I looked at my NAnt
csc target, the sources referenced my build destination instead of the sources. A quick fix results in a fix to the problem:
1 2 3 4 5 6 7
So, in a nutshell, if you receive the error listed above and are using NAnt to automate your deployment, pay attention to the fact that your build sources are correct. Thankfully this wasn’t a weeklong ordeal like it could have potentially become.