What is the best way to add a custom webpart to a sharepoint default page(i.e list page like NewPost.aspx) and/or into the webpart gallery programmatically without directly deploying from Visual studio.
What I did:
1) Created a custom Visual webpart solution in Visual Studio.
2) Directly deployed my custom webpart into my dev site.
3) Then I published the custom webpart(*.wsp).
4) I exported my custom webpart from dev site which had the assembly reference of webpart and some of its properties as below.
<webParts> <webPart xmlns="http://schemas.microsoft.com/WebPart/v3"> <metaData> <type name="CstmWebpart.BlogPosts.CreateandEditBlogPosts.CreateandEditBlogPosts, CstmWebpart.BlogPosts, Version=184.108.40.206, Culture=neutral, PublicKeyToken=51ad286432a40bbb" /> <importErrorMessage>Cannot import this Web Part.</importErrorMessage> </metaData> <data> <properties> <property name="ExportMode" type="exportmode">All</property> .. .. .. </properties> </data> </webPart> </webParts>
5) After that I deployed the webpart solution(*.wsp) into my target site which is another machine using
6) Then I uploaded and added the exported webpart (*.webpart) into target site, which throws error as shown in below image.
7) If I upload the exported the webpart into the same dev site, its working.
Am I doing it in the right way? Any help would be greatly appreciated.