2
votes

I just wrote a new web part and now I am getting this error when I try to deploy them on my non-dev servers:

the default namespace 'http://schemas.microsoft.com/WebPart/v2' is a reserved namespace for base Web Part propertiees. Custom Web Part properties require a unique namespace (specified through an XmlElementAttribute on the property , or an XmlRootAttribute on the class).

I am writing the web parts into CAB files and deploying them with this:

stsadm -o addwppack -filename web_part_name.CAB -url http://your_url_here -globalinstall -force 

Everything works fine until I try to add the web part, then I get this error in a popup. It works just fine on my dev VM...?

Any ideas would be appreciate, thank you.

4

4 Answers

1
votes

Well, it looks like your webpart definition file si somehow broken. The wey i do it is to put webpart into page and then export it. You can do this just by opening webpart galery, which can be located in site settings of root site collection and add your webpart there.

After that just place webpart to any page and use export button in webpart settings. This will produce .webpart or .dwp file depending on your webpart (.webpart is 'new' definition which is used by webparts native to MOSS 2007 and .dwp is for older webparts, but it depends how you have written your webpart)

Then just take exported file and include it into your project. This approach works for me at least.

0
votes

Did you package your webpart as a .webpart file ?

If this is the case, you have to use the new v3 namespace. To use the v2, you have to package it as a .dwp file.

0
votes

Yes, your web part definition file (*.dwp or *.webpart) is probably not correct. Post it here, and it should be swift to find the error.

0
votes

A bit of a educated guess here but anyway :-

First check that you have XmlRoot attribute like this in your web part

[XmlRoot(Namespace = "Your.Namespace")]
public class YourWebPart: WebPart
{
...

and XmlElement attribute on your custom properties

    [DefaultValue(0)]
    [WebPartStorage(Storage.Shared)]
    [Browsable(false)]
    [XmlElement(ElementName = "YourProperty")]
    public Int64 YourProperty
    {         
       ...
    }

This error is happening when .NET is attempting to desterilize the data from the .DWP file and set the custom properties in your web part.

I suspect that the error may have nothing to do with namespace conflicts as SharePoint sometimes tends to fall back to an error messages that can be a red herring.

I would firstly examine your .dwp file. Do you have any custom properties set there, if so remove them and retest.

Comment out the custom properties in your web part code one by one and retest at each step.

I think you will find one of these is causing the problem - exactly why is the next question!