Another Good Bug Bites Us in VS2003 - Classic ADO
One of the services that my team had to write here at work included the necessity to be able to send an email with an attachment. While clunky in .net 1.1, it was doable.
But when we noticed that to send an attachment you could only specify a file location for it, we started looking elsewhere. There's numerous components out there, but it all came down to the same thing: a managed wrapper around CDO.
CDO is a weird little beasty, and itself has dependancies on classic ADO objects - the two we had to use was the Fields collection, and the Stream (for in-memory attachments).
The service was written, and worked fine. It went to test and worked fine there too.
Then nothing happened for a couple of months (I'm used to that).
Then it went to prod.
And it won't send mail.
For the last few weeks, as time has permitted, we've been trying to work out why. A quick win forms test app that could be run by an administrator also had the same problem - crashing and burning when touching an ADO object.
I finally tracked it down today. There's a bug in visual studio such that, when you make a reference to classic ADO by browsing to the ado dll, it generates the Interop dll for you, but makes a reference to the installed PIA version that's living in the GAC. The PIA version gets installed when you install Visual Studio.
Oops :) We still wouldn't have been bitten by the bug, except that when the service (windows service this is) was deployed, the guys who wrote it didn't write an installer, only instructions on how to register the service with windows via the command line. If an installer had of been made (using a VS Setup Project) then the PIA would have been included in the MSI and installed in the GAC at install time.
Having tracked the problem down myself, I finally found official doco from Microsoft about it.
I worked out the specific problem by comparing what was registered in the gac on two different servers, and then realised that the on which worked (in test) had SQL Reporting Services 2000 installed on it. Having realised that our code was only calling the gac version, I trawled the Reporting Services install disc and found the pia in there :)
Interestingly however, the DLL Help Database that lists all packages that contain different dll versions doesn't list Reporting Services. It only mentions VS 2002 and 2003, Exchange, Biztalk, Commerce Server and Small Business Server. Maybe the RS guys didn't realise this happened either, and the installer just included the dll... *grin*