Prologue:
There are times when I am a click or two away from registering some derivative of IHateSharePoint.com or SharePointIsKillingMe.com or WasSaneBeforeSharePoint.com. I was VERY close after encountering the following problem…
Act I Scene I
I had been through the Code – Build – Debug cycle with this particular feature numerous times (especially the Debug step). Suddenly one of the builds resulted in the informative web part error:
…which I have seen before – but usually only when the web part is first deployed. 99% of the time this error is caused by the entry for your web part in the SafeControls section of the web.config file. It usually boils down to something like a spelling error, the namespace, assembly version, etc.
ACT I Scene II
Remove the code I just added. No dice – same issue.
ACT I Scene III
IISRESET. Strike two – same issue.
ACT I Scene IV
Remove code I added several builds previous. Same issue.
ACT I Scene V
Re-add the feature and web part to the page. Adding web part fails. Interesting. Upon navigation to home page, notice that ALL web parts are showing errors – even the out of the box ones. Also interesting in a ‘just what I needed’ sort of way.
Intermission
Magic reboot. Same issue. Strange, because magic reboots rarely fail to resolve issues.
ACT II SCENE I
Hit up the internet to see what he knows. Typical stuff: make sure there is a SafeControls entry, make sure it is right, etc. etc. Found some good posts about what to check. Here are a few of them:
- Has some complaints for MS: http://williamvanstrien.blogspot.com/2009/07/difficult-upto-impossible-to-derive.html
- Similar problem to mine: http://stackoverflow.com/questions/549198/web-part-deployed-to-gac-not-working
- Good checklist to go through if you get this error: http://www.mikhaildikov.com/2008/03/unable-to-add-selected-web-parts.html
Check on all of it for me though – double checked in fact. Re-add assemblies to GAC just in case. Same issue.
ACT II SCENE II
Restore a web.config from previous day. SAME ISSUE.
Act II Scene III
Crank up ULS logging level to the deepest depths of verbosity – you know, the ‘disk filler and killer’ levels. But they gave me no additional information – showed me the same as what is rendered within page…
Act II Scene IV
Restore web.config from previous month. All web parts back up except the one I had been working on, which did not exist a month earlier.
Epilogue
So it was web.config related, and also probably an issue with my custom web part. After some experimentation, it turned out to be the entry in the SafeControls section. But not because it was invalid – remember I checked that in act 2 scene 1 – it was because the assembly could not be loaded because one of its dependencies could not be found. Why could it not be found? It was not in app’s bin folder or in GAC. Easy enough to fix once I finally found the real problem. My questions are:
> Why did this not show up as an error somewhere? I could have solved it within minutes rather than burning an entire afternoon.
> Why did this kill ALL SafeControls in the SafeControls section of the web.config, and not just the ones within the problematic entry? If there is a problem with a SafeControl node, the typical behavior is that it only affects anything in that namespace, not every SafeControl node.
Pray for no sequel!
No comments:
Post a Comment