I have SharePoint solution, which contains template, multiple libraries, web-parts and etc... In this case I have found a bug in one of my web-parts. How I can only update that one web-part, so I can fix the bug?
I think that I need to create Visual Studio project which contains only web-part. I don't have Visual Studio in my production server, so I cannot use it to deploy solution. How I can deploy webpart.wsp correctly to solution? Do I have to remove someway web-part first or what is to correct way fix web part?
Can you please guide me, how I can fix it?
After I run Update-SPSolution, SharePoint web-parts gives me an error message: $Resources:core,ImportErrorMessage;
I checked that web-part feature is activated and it can be found in Site settings / Web Designer Galleries / Web parts. But if I try open it, it gives me same error message.
I used SharePointLogViewer:
Error importing WebPart. Assembly EBIC SPF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=90615eedf85cc25e, TypeName. Full_Template.WebParts.PersonalItems.PersonalItems. $Resources:core,ImportErrorMessage;
Application error when access /_layouts/15/WPPrevw.aspx, Error=Object reference not set to an instance of an object. at Full_Template.WebParts.PersonalItems.PersonalItems.<>c__DisplayClass5.<.ctor>b__0() at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.b__3() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Full_Template.WebParts.PersonalItems.PersonalItems..ctor()
System.NullReferenceException: Object reference not set to an instance of an object. at Full_Template.WebParts.PersonalItems.PersonalItems.<>c__DisplayClass5.<.ctor>b__0() at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.b__3() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Full_Template.WebParts.PersonalItems.PersonalItems..ctor()
Getting Error Message for Exception System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> Microsoft.SharePoint.WebPartPages.WebPartPageUserException: $Resources:core,ImportErrorMessage; ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Full_Template.WebParts.PersonalItems.PersonalItems.<>c__DisplayClass5.<.ctor>b__0() at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.b__3() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCal...
...lback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Full_Template.WebParts.PersonalItems.PersonalItems..ctor() --- End of inner exception stack trace --- at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.Creat...
Web-part is big so I add only parts of code:
Guid siteID = SPContext.Current.Site.ID;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(siteID))
{
using (SPWeb web = site.OpenWeb())
{
try
{
SPList oList2 = web.Lists["config"];
SPListItemCollection collListItems2 = oList2.Items;
foreach (SPListItem item in collListItems2)
{
// LOOP ITEMS
}
catch (Exception ex)
{
Label label = new Label();
label.Text = "DEBUG: " + ex.Message + "INNERDEBUG: " + ex.InnerException.Message;
//label.Text = ex.Message;
this.Controls.Add(label);
}
}
}
});
SPSite siteColl = SPContext.Current.Site;
SPWeb site = SPContext.Current.Web;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite ElevatedsiteColl = new SPSite(siteColl.ID))
{
using (SPWeb ElevatedSite = ElevatedsiteColl.OpenWeb(site.ID))
{
SPUser currUser = site.CurrentUser; //not the ElevatedSite.CurrentUser
loggeduser = currUser.ToString();
// parse logged user account
int i = loggeduser.IndexOf('\\') + 1;
string d = loggeduser.Substring(i);
d.Substring(1);
loggeduser = d;
}
}
});
SPSecurity.RunWithElevatedPrivileges(delegate()
{
foreach (SPWebApplication webApp in SPWebService.ContentService.WebApplications)
{
foreach (SPSite siteCollection in webApp.Sites)
{
foreach (SPWeb web in siteCollection.RootWeb.GetSubwebsForCurrentUser())
{
if (web.ID.ToString() == orgPageFromUrl)
oWebsite = web;
}
}
}
});