Stupid Code To The Rescue!
secretGeek .:dotnuts about dotnet:.
home .: about .: sign up .: sitemap .: secretGeek RSS

Stupid Code To The Rescue!

A big dose of .NetFrustration this morning.

When you upgrade an assembly from version 1.0 to version 1.1 you are likely to get a lot of squiggley blue lines and warnings such as:

OR:

OR worse yet:

Google turned up blank, MSDN turned up blank, but I finally got rid of the warnings, by writing stupid code.

(Read on for some dodgy solutions and some stern lectures. :+))

For example:

Rather than:

I would write:

And voila! it works just fine.

The next failed piece of upgraded code was this

In this case you need to add two more parameters, an 'XMLResolver' and an 'evidence' param. This worked:

Evil Moral of the story is:

If a parameter is required, but you don't know why, just set it to 'nothing.'

That's not the sort of lesson I'd like to teach people. But it's what Microsoft taught me today.

Third situation was a bit trickier and called for an even nastier hack.

This worked in version 1.0, but threw a warning in 1.1:

The warning was a familiar one:

My first thought was: 'add a new parameter, value of nothing'. But this failed because the compiler couldn't resolve which overloaded interface I was after. The result of such an approach was:

i.e., 'Sure you want nothing -- but what type of nothing??' Fair cop, so I tried this instead:

Now there were no warnings and it did compile. But did it work? Who cares? Because right then i thought of a cleverer and nastier solution, that would be bound to confuse other developers. Naturally, I gravitated toward it immediately:

I didn't test that it worked, because 'hey, it should, right?'

At that moment, another, nastier solution occurred to me. I call this one: "What type of 'nothing'? **This** type of nothing!"

No time to test it, but the compiler doesn't freak, so my money says she works.

And now I can get on with writing other, better, faster bugs.

As an old friend said to me just yesterday: "One man's bug is another man's paycheck."


Add or view comments about this page

Articles

Do they store the code for TFS in TFS? Do they store the code for TFS in TFS?
Sudden TimeSnapper Discount! Sudden TimeSnapper Discount!
How Can Microsoft Beat Google? How Can Microsoft Beat Google?
TimeSnapper 3.1: Attack of the the Red/Green Stripes TimeSnapper 3.1: Attack of the the Red/Green Stripes
21 tools used in our MicroISV 21 tools used in our MicroISV
Lost Treasures of the DOS World: tree! Lost Treasures of the DOS World: tree!
The Virtual Machine Machine and the Virtual Virtual Machine The Virtual Machine Machine and the Virtual Virtual Machine
Should Linq To Sql Go Should Linq To Sql Go "Open Source"?
Redux: New Synchronisation Idea Overlooked By Microsoft Redux: New Synchronisation Idea Overlooked By Microsoft
New Synchronisation Idea Overlooked By Microsoft Live team New Synchronisation Idea Overlooked By Microsoft Live team
Visual Studio UX Taskforce, Office UX Taskforce... etc. Visual Studio UX Taskforce, Office UX Taskforce... etc.
How to be Jeff Atwood How to be Jeff Atwood

Archives .: secretGeek :: Complete Archives :.
25 steps for building a Micro-ISV 25 steps for building a Micro-ISV
3 minute guides -- babysteps in new technologies: powershell, JSON, watir, F# 3 Minute Guide Series
Top 10 SecretGeek articles Top 10 SecretGeek articles

Downloads

TimeSnapper -- Automated Screenshot Journal TimeSnapper.com    
Version 3.1: instant productivity profiles

ShinyPower (help with Powershell) ShinyPower
Now at CodePlex

Next Action NextAction
Managing the top of your mind



[powered by Google] 


Thai Erawan, Brisbane Restaurant, delicious thai food in paddington Thai Erawan, Brisbane Restaurant
World's Simplest Code Generator (html edition) World's Simplest Code Generator
Gradient Maker -- a tool for making background images that blend from one colour to another. Forget photoshop, this is the bomb. Gradient Maker
How to be depressed How to be depressed
You are not inadequate.



Recommended Reading

The Best Software Writing I
The Business Of Software (Eric Sink)

Recommended blogs

Jeff Atwood
Reginald Braithwaite
Joseph Cooney
Phil Haack
Scott Hanselman
Julia Lerman
Joel Pobar
Eric Sink
Joel Spolsky
Des Traynor

Aggregated Links

programming.reddit.com
dzone
dot net kicks

Human Link Machines

interesting finds
a continuous learner's weblog
arjan's world
n links today
new and notable
morning coffee
learning .net
weekly link post
(my del.icio.us account)

LinkedIn profile
 
home .: about .: sign up .: sitemap .: secretGeek RSS .: © Leon Bambrick 2003 .: privacy

home .: about .: sign up .: sitemap .: RSS .: © Leon Bambrick 2003 .: privacy