部署的Web部件未显示在“Web部件库:新Web部件”中
-
03-07-2019 - |
题
我拿了一个wsp文件,像往常一样做了 stsadm -o addsolution 。然后我进入中央管理 - >解决方案管理,它显示就好了。然后我部署了Web部件,到目前为止没有任何问题。
问题是,当我将其添加到webpart库( Web部件库:新Web部件)时,通常Web部件位于列表中,我选中它旁边的框并单击填充图库,但它没有显示在列表中?我可以在manifest.xml中遗漏一些东西吗?我只是以相同的方式编写并部署了另一个Web部件完全并且它很好。另外,我写了一个虚拟的webpart,除了打印“工作”之外什么都不做。并试着用它获得相同的结果。
有什么想法吗?
解决方案
其他提示
检查.webpart文件是否已部署到您网站的wpcatalog文件夹中。根据配置Web应用程序时指定的目录,您应该在类似于以下位置找到它:
C:\的Inetpub \ wwwroot的\ WSS \ VirtualDirectories \ 80 \ wpcatalog
我遇到了与我一直在处理的Web部件相同的问题但在我的情况下,我只是忘了将Web部件添加到“功能中的项目”框中。要做到这一点:
- 在解决方案资源管理器中展开您的功能的子树。
- 双击以
.feature
结尾的项目。 - 您应该会看到一个包含功能标题,说明和范围的新标签页。在它们下面有两个盒子,中间有按钮。从左侧框中选择您的Web部件,然后按
>
按钮(在图像上标记)将其添加到功能部件。
醇>
注意:您也可以通过按下底部的 Manifest
按钮并手动编辑Manifest文件来完成此操作,如果您知道自己在做什么。
这确实可以帮助其他SharePoint初学者。
我有时候有同样的行为。最后,我们编写了一个cmd工具,它运行“stsadm - o addsolution”。然后将Web部件库的所有xml文件添加到Web部件库中。
有源(少量编辑):
string cmd_StsAdm = @"C:\Program files\Common files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe";
string url_Site = "http://localhost";
string url_Web = "http://localhost";
if ( string.IsNullOrEmpty( url_Web ) ) { url_Web = url_Web; }
Console.WriteLine( "Deleting sharepoint solution" );
string args_DeleteSolution = string.Format( "-o deletesolution -name \"{0}\" -override", startInfo.fileNameWsp );
ShellWait( cmd_StsAdm, args_DeleteSolution );
string filePathWsp = "**** path to wsp file ****";
Console.WriteLine( "Adding sharepoint solution" );
string args_AddSolution = string.Format( "-o addsolution -filename \"{0}\"", filePathWsp );
ShellWait( cmd_StsAdm, args_AddSolution );
Console.WriteLine( "Deploy sharepoint solution" );
string args_DeploySolution = "-o deploysolution -name \"{0}\" -local -allowGacDeployment -url \"{1}\" -force";
args_DeploySolution = string.Format( args_DeploySolution, startInfo.fileNameWsp, url_Web );
ShellWait( cmd_StsAdm, args_DeploySolution );
int counter = 0;
foreach ( CWebPartVytvoreniInfo wpRslt in solutionInfo.WebParts ) {
counter++;
string msg = string.Format( "Aktivace web part {0} - {1} z {2}", wpRslt.Info.Nazev, counter, solutionInfo.WebParts.Count );
Console.WriteLine( msg );
string args_ActivateFeature = "-o activatefeature -id {0} -url {1}";
args_ActivateFeature = string.Format( args_ActivateFeature, wpRslt.Info.ID, url_Site );
ShellWait( cmd_StsAdm, args_ActivateFeature );
}
Console.WriteLine( "Connecting to sharepoint site" );
using ( Microsoft.SharePoint.SPSite site = new Microsoft.SharePoint.SPSite( url_Site ) ) {
Microsoft.SharePoint.SPList ctg_WebParts = site.GetCatalog( Microsoft.SharePoint.SPListTemplateType.WebPartCatalog );
counter = 0;
foreach ( WebPartInfo wpInfo in solutionInfo.WebParts ) {
counter++;
string dirPath = System.IO.Path.Combine( wpInfo.DirectoryPath );
string fileName = wpRslt.Info.Nazev + ".webpart";
string filePath = System.IO.Path.Combine( dirPath, fileName );
string msg = string.Format( "Uploading file '{0}' - {1} z {2}", fileName, counter, solutionInfo.WebParts.Count );
Console.WriteLine( msg );
using ( System.IO.FileStream fstrm = OtevritSoubor( filePath ) ) {
ctg_WebParts.RootFolder.Files.Add( fileName, fstrm, true );
}
}
}
我发现,如果我部署之前已损坏的Web部件,则必须在删除解决方案后手动将其删除,然后再重新添加解决方案
目标.NET Framework对我来说是个问题。我针对.NET 3.5而且这对我不起作用。所以我改为针对.NET 3.0,而且效果很好。