Will Memory Erosion still take effect, even though the spell has been countered? Or does the spell need to resolve first for Memory Erosion's abilty to take effect?
Memory Erosion triggers when an opponent casts a spell, not when they resolve the spell. Memory Erosion's triggered ability will already be on the stack before Player A even has the chance to cast their counterspell.
The stack will look like this:
When Counterspell resolves, Dark Banishing will be removed from the stack and placed in its owner's graveyard, as will Counterspell itself, leaving Memory Erosion's triggered ability alone on the stack. Memory Erosion's ability will then resolve once both players pass priority again, and Player B will place the top 2 cards from his library into his graveyard.
Note: Because objects on the stack don't resolve until both players pass priority, Player A could potentially opt to wait for Memory Erosion's trigger to resolve before casting Counterspell. Player A would get to see what two cards are put into the graveyard and based on that extra information, may decide whether countering Dark Banishing is still worthwhile. (For example, Player B might "mill" a card with Flashback that Player A wants to counter even more than Dark Banishing, so he would hold on to his Counterspell.)
In short: Yes, Memory Erosion will still work, even though the triggering spell was countered.
"Casting a spell" refers to
A spell is cast as soon as these steps are completed. Casting a spell does not include resolving the spell or anything in between.
Countering a spell after it has been cast does not undo the fact that it had been cast, so it does not affect Memory Erosion.
Memory Erosion will resolve. (As such, Player A might as well wait for Memory Erosion to resolve before deciding whether to counter Dark Banishing or not.)