Problem:
When trying to enumerate web parts on a site all web parts appear as ErrorWebPart. There are OOB and custom web parts on the site.
In my case I have a Web Service that is used to create new MOSS sites. At some stage I need to define the Audience setting of some web parts and it has to be done programmatically. As far as I know, Audience settings cannot be set in Site Definitions. Please let me know if it is possible.
Solution:
Put all custom web parts in GAC. It appears that if even one custom web part has problems with permissions (not in GAC or otherwise not trusted), all web parts appear as ErrorWebPart.