We are having problems with our CQWPs when deploying our site to another environment. So the original issue was, the ListGuids are different on each environment so the CQWP throws an error after deployment.
So our solution was to edit each CQWB using a ps1 script (PowerShell) using the $web.GetLimitedWebPartManager() method.
Now the problem is, since the WebPart is has the wrong list guid, it is in an error state and therefore shows up as an ErrorWebPart in the WebPart collection.
So the questions are:
- Is there any way to get the underlying web part from the ErrorWebPart and update it
- Is there any other automated way for us to edit web parts in a page
its a catch22. We cant update the webpart until its fixed but we cant fix the web part if we cant update it.
Now we have found out that the errorweb parts are caused by custom xsl files that we use. The problem is better described here: http://vspug.com/koning53/2007/11/26/bug-in-contentbyquerywebpart-when-opened-in-a-non-web-context/
Now what I want to do is spoof the http context so I can retrieve the CQWP or if that's not possible, get the underlying webpart that has been substituted by the errorwebpart