The expanded web part does not appear in the Web Part Gallery: New Web Parts

I took the wsp file and made my stsadm -o addolution , as usual. Then I went to the central administration → decision management, and it seemed just fine to me. Then I deployed the web part, no problem so far.

The problem is when I add it to the web part gallery (Web Part Gallery: New Web Part), usually the web part is on the list, I check the box next to it and click fill gallery but it does not appear in the list ? Can I skip something in my manifest.xml to trigger this? I just wrote and deployed another web part in the same way, and everything went well. In addition, I wrote a dummy website that does nothing but print “worker” and tried it, getting the same results.

Any ideas?

+3
source share
6 answers

wow ... it turns out that all I was missing was the "public" declaration in my class!?!

. , . !

+6

, .webpart wpcatalog -. , -, :

C:\Inetpub\Wwwroot\WSS\VirtualDirectories\80\wpcatalog

+2

-, , - " " . :

  • Solution Explorer .
  • , .feature.
  • , . . - > ( ), .

. , Manifest , , .

Adding Web Part to Feature

SharePoint.

+2

. , cmd-, "stsadm-o addsolution", - xml -.

( ):

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 );
        }
    }
}
+1

I found that if I deployed a web part that was previously borken, I had to manually delete it after deleting the solution, before re-adding the solution

+1
source

The target .NET Framework was a problem for me. I aimed at .NET 3.5 and it did not work for me. So I aimed at .NET 3.0, and it worked out well.

0
source

Source: https://habr.com/ru/post/1698345/


All Articles