尝试部署 Web 部件时出错
我刚刚编写了一个新的 Web 部件,现在当我尝试将它们部署到我的非开发服务器上时,出现此错误:
默认命名空间 'http://schemas.microsoft.com/WebPart/v2' 是为基础 Web 保留的命名空间 部分财产。 自定义 Web 部件 属性需要唯一的命名空间 (通过指定 属性上的 XmlElementAttribute , 或类上的 XmlRootAttribute)。
我正在将 Web 部件写入 CAB 文件并使用以下命令进行部署:
stsadm -o addwppack -filename web_part_name.CAB -url http://your_url_here -globalinstall -force
一切正常,直到我尝试添加 Web 部件,然后在弹出窗口中收到此错误。 它在我的开发虚拟机上运行得很好...?
任何想法将不胜感激,谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
嗯,看起来您的 Web 部件定义文件不知何故损坏了。 我这样做的方法是将webpart放入页面然后导出。 您只需打开 Web 部件库即可完成此操作,该库可以位于根网站集的网站设置中,并在其中添加您的 Web 部件。
之后,只需将 Webpart 放置到任何页面并使用 WebPart 设置中的导出按钮即可。 这将根据您的 webpart 生成 .webpart 或 .dwp 文件(.webpart 是 MOSS 2007 原生的 webpart 使用的“新”定义,.dwp 用于较旧的 webpart,但这取决于您编写 webpart 的方式
)获取导出的文件并将其包含到您的项目中。 这种方法至少对我有用。
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.
您是否将 webpart 打包为 .webpart 文件?
如果是这种情况,您必须使用新的 v3 命名空间。 要使用 v2,您必须将其打包为 .dwp 文件。
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.
是的,您的 Web 部件定义文件(*.dwp 或 *.webpart)可能不正确。 把它贴在这里,应该很快就能找到错误。
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.
这里有一点有根据的猜测,但无论如何:-
首先检查您的 Web 部件中是否有这样的 XmlRoot 属性
,以及您的自定义属性上的 XmlElement 属性
当 .NET 尝试对 .DWP 文件中的数据进行反消毒并且在 Web 部件中设置自定义属性。
我怀疑该错误可能与命名空间冲突无关,因为 SharePoint 有时会回退到可能会转移注意力的错误消息。
我首先会检查您的 .dwp 文件。 您是否在那里设置了任何自定义属性,如果有,请将其删除并重新测试。
将 Web 部件代码中的自定义属性一一注释掉,并在每个步骤中重新测试。
我想你会发现其中一个是导致问题的原因 - 到底为什么是下一个问题!
A bit of a educated guess here but anyway :-
First check that you have XmlRoot attribute like this in your web part
and XmlElement attribute on your custom properties
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!