Sep 22 2006

Build events - howto part 12

Posted by admin under In practice

While the solution downloadable in part 11 is "ok"  - I can almost bet that the first time you create such a solution yourself - or even if you just decide to develop a new DAL driver for this particular project I can almost bet you will get an error like

NullReferenceException was unhandled by user code

And it's pointing to the instantiation part of our DAL. No worry - it does NOT have to mean you have configured the web.config entry incorrectly (although it could) - but first make sure the driver dll is copied to the bin directory of your web application.

Since the web application does NOT reference the dal driver dll ( it shouldn't - instead it references the interface dll only) - the DAL driver will not be copied to the bin folder automatically.

Cause this is the behaviour we want, right. Just to copy a (newly developed)dal driver dll file into the bin, configure web.config - and then go!

But when developing, debugging and running from VS2005 is might be timeconsuming to do this manually eash time. So, lets create at Build event for the CustomerDAL_SQLServer project:

As a post-build event we copy the CustomerDAL_SQLServer.dll to the bin directory of the DemoUpload project (i.e web application)

copy $(TargetPath)  $(SolutionDir)\demoupload\bin\$(TargetName)$(TargetExt)