Monday, 7 December 2009

An error occurred while validating. HRESULT = '80004005'


You may have received this error when compiling a setup project within visual studio...

Roughly translated, this error message means "Cannot built setup, dependent project is missing, missing a reference or a referenced file for a project cannot be found."

For example, add a project output to the setup file, and apply one of the content files to the setup (I.e. use an icon for the add/remove programs icon). Remove the project out, then re-add it. Visual studio will then give you this error (despite the project output being in there!!)... Everytime an output is removed, you must re-reference all of the dependencies.

If it is not this specific issue, then there is something wrong with your projects. Look up the projects' references and see if they are all correct. Try to compile the projects as well, this is a good indication that you aren't adding projects with errors to your set-up!

Adding a project/installer to VSS (where you want it to go!)


If you have a solution in visual studio, its probably made up of many relationships and dependencies. If the solution isn't source controlled immediately, you might run into a couple of issues putting it in Visual Souresafe (VSS) exactly where you want it to go.
The same goes for installers, and adding new installers to an existing source controlled solution.

The key is to add it to VSS before dependencies are added... otherwise, it'll pick up the fact that its above the binding root of the solution, and put it inside the folder you want, but inside two child nodes down; or something silly like that.

So the best way is to remove dependencies, or source control it before they are added!

Friday, 4 December 2009

Attach a database file to SQL Server


If you have a SQL Server Database file (.mdf) and the associated logfile (.ldf), you can attach this manually to an SQL Server database.

Here's a Microsoft link explaining the process:

BackgroundWorker - Handling Exceptions


Today i've been using Background Workers in visual studio and came to a bit of a fix when I needed to throw an expcetion within the DoWork event of the worker.

Normally, you would expect to throw exceptions as usual, but due to the nature of how the worker handles exceptions; this is done a little differently...

The worker automatically handles exceptions and passes them as an argument to the RunWorkerCompleted event. From the developers perspective, you just need to throw them within the DoWork event.
In the RunWorkerCompleted event, the RunWorkerCompletedEventArgs object contains an "Error" property. Simply test for null here to know weather an error has occurred... here you can catch your exception!