a collection of technical fixes and other randon stuff


  • Join Us on Facebook!
  • Follow Us on Twitter!
  • LinkedIn
  • Subcribe to Our RSS Feed

How to fix error: Cannot bind argument to parameter 'Path' because it is null when running update-database in package manager


This has caught me out on a few occasions:

When trying to run the

update-database command in Package manager within visual studio , i repeatedly got the error:

Join-Path : Cannot bind argument to parameter 'Path' because it is null.



In this instance, i was not pointing the "Default Project" to the data project that I was using.

Simply choose it from the options within the package manager window and re-run the update command.

This should solve the problem.



What the f**k is a 'Delegate' in programming?

I have rarely come across a good article on delegates, and after 20+ years in programming I'll have a go at explaining it myself.

I've often struggled to understand the concept, it's use, benefits whilst actually having implemented them quite well.

Q: "...so what the fuck are delegates?"

"A delegate is a type that represents references to methods with a particular parameter list and return type. When you instantiate a delegate, you can associate its instance with any method with a compatible signature and return type. You can invoke (or call) the method through the delegate instance"

Q: "...so what the fuck are delegates?"


...Okay... you get my point!!!??? When you explain it in programming language, it kind of loses it's practical meaning (unless you eat, sleep, breath coding.)

Q: "...so what the fuck are delegates?"


Well firstly, it helps if you are familiar with the concepts behind: methods,events and reflection and multi-threading.
You only need a little knowledge from each area to follow this article further, namely:

  • You should be aware how to write a method or function. If not go away now, why the hell are you reading this article?
  • You should know that,  with little code, some pretty clever things can be done using reflection, and you can manipulate objects based on what information your code knows about it's type and properties.
  • You should know multithreading is a way of firing off lots of processes at once to hopefully speed things up.


Lets go back to the answer i copied from wikipedia earlier and give an example.

say we have two functions:

string HowExplosive(string animalName, string vegetableName)


string HowTasty(string animalName, string vegetableName)

Both these functions take 2 strings as parameters and return a string as their output value.
They have the same characteristics, so we could describe all methods that have these characteristics by giving them a type.

Let's give them a type of DumbAssSillyFunctions. Lets code it!.....

public delegate int DumbAssSillyFunctions(string animalName, int vegetableName);

and there we have it..... a delegate....it tells us all DumbAssSillyFunctions
take 2 strings , one for animal name and one for vegetable name. And they also return a string.

Having established a way of classifying methods with this delegate/type we've got ourselves some information about our code. Information about code is how reflection works so you should be thinking that we have an opportunity here to reduce code and handle multiple situations.

You should also know that events are very similar to functions and so could also be described using a delegate statement, which often happens.

Are you understanding yet?  Now why did i mention reflection earlier????

Consider this.... your program is receiving inputs of different combinations of animals and vegetables..

Cow, Carrot
Sheep, Turnip
Lamb, mint



Lets take this to the extreme...suppose we wanted to analyse every vitamin and mineral content for each combination... We could hard code all the method calls....or....... we could use reflection to loop through all methods available and find the methods that are of type


When we find a function that matches, we know to pass the animal in first and the vegetable in second, and we will get a result.
This lets our loop execute without knowing anything about the function names or how many there are.
....so we can add more features without breaking or having to modify the main loop.

This is an example of one routine calling many, and we can see how this can be used to launch multiple threads in a multi-threaded application.

Now lets reverse it and see how we can have multiple things calling one method to implement code re-use. Suppose we have some "FoodComboAnalyser" objects.
If we gave all these events of a delegate type "CrazyAlert", one of these may fire if the animal an vegetable are too explosive. The other may fire if it is particularly tasty.
We may want to log these down or show a message when they occur.

We can do this by assigning a handler to the events. The handler will also have a matching delegate type. Once linked, the event handler catches the events and carries out the actions on the information passed to it.
This is how a lot of visual programming languages work by handling onclick, onfocus, on keypress etc...

Continuing the handling of events... an extreme example of event management is the Node.js framework, and i recommend the "codeschool.com" tutorial on it.
Here they explain the event loop which constantly listens for events and handles them by passing the data onto processing functions.

Watch it and you may note, that it is a pretty impressive way of handing out work. I likened it to a super-duper Project Manager handing out lots of work to other people...

or delegating ...to delegates...

Has it clicked yet? :)




ASP,net Compiled DLLs and simplifying builds

Recently i've needed to understand more about the methods and naming of compiled dlls in an ASP.net website.

I'd come across a problem in a system that auto updates it's self, and the fact that we wanted to do controlled partial updates to the system.

What i had noticed in testing is that some developers code produced lots of .compiled files and strangely named dlls , whereas others had just one or two files when the site was published.

This was a big problem when looking at the update process because if a customers site has a mixture of the two release methods, then it was pretty much guaranteed to fall over with error messages like 

"The file has not been precompiled".

 Two options

 In Visual Studio 2008, you get an option when publishing a web site to "Allow this precompiled site to be updatable".

When not selected, each asmx asn aspx page gets compiled to it's own dll and a .compiled file is created for each page also. To cut a long story short, this makes the client side content of your pages uneditable and more secure. The ".compiled" files reference the relavant dlls and provide checksums to ensure they are valid.

When selected, the file list becomes much simpler with fewer dlls and ".compiled" files.

Facing future updates and testing of code releases, the latter option sounds the most promising and most managable but there are still a few files that cause cause a bit of head scratching.


App_Web_xxxx.dll (sometimes several of these)



These little guys offer the most confusion for our planned auto update service because the name of these files changes with each build and are pretty randomised. This can pose a big headache when trying to know which dlls to replace, add or delete. Without a solution, the only alternative is to do updated of the whole bin director.

Luckily there is, but first, an explanation of the files and what you can do to reduce them.

  •  App_Code.dll - Is where all your classes reside. Basically everything that has come from your App_Code folder in Visual Studio gets compiled into here.
  • App_Web_xxx.dl -This contains all "CodeBehind" code. Typically the c# or VB classes that are in files outside of the  App_Code folder. (aspx pages etc...). I've found that you are more likely to have more of these if web pages have the same class definitions in them. "public partial class _default" was a classic example in some of my files. You can reduce the number of dlls byreducing this duplication.
  • App_global.asax.dll - ??????????????????????????

A Nicer Way

There is a nice tool called "Web Deployment Projects for VS 2008." A walkthrough and download is available here.

Oncedownloaded and installed you get an extra option in the build menu and whe nright clicking on your solution. This allows you to ass a deployment project. 

Like publishing,setting properties and for the new project will allow you to choose  "Allow this precompiled site to be updatable". But also allows you to merge the nasty dlls into one and ensure the dll always has the same name.

Basically, App_Code.dll, App_Web dllls and App_global dlls merge into one so, you dont have to remember which dll is required for your fixes or updates later on.