Hi Guys,
You may have faced this kind of error while coding the webparts and provisioning them in SharePoint pages. May be you will face this issue while trying to edit a page, that having the webpart with below code
using(SPWeb web = SPContext.Current.Web)
{
//Your code here
}
Issue is with using statement, its disposing your SPWeb object automatically when you leaving using block. Use below than the above block
SPWeb web = SPContext.Current.Web
Hope you will figure it out within your code.
Happy coding guys,
Buddike
Trying to share development research findings while applying for day to day life.
Showing posts with label sp. Show all posts
Showing posts with label sp. Show all posts
Wednesday, November 7, 2012
Tuesday, October 30, 2012
Debugging a Timer job
Hi Friends,
May be you are running with the time for creating Sharepoint timer job creation. You have started to create a feature with Event receivers, feature receivers and basic timer job class structure like below.
public class TimerJobClass : SPJobDefinition
{
//Your contructors to handle different combinations of parameters
public TimerJobClass()
{
}
public TimerJobClass(string jobName, SPService service, SPServer server, SPJobLockType targetType)
: base(jobName, service, server, targetType)
{
}
public TimerJobClass(string jobName, SPWebApplication webApplication, string targeturl)
: base(jobName, webApplication, null, SPJobLockType.Job)
{
this.Title = "Timer Job Name";
}
public override void Execute(Guid contentDbId)
{
//Things need to do.
}
}
After this structure declaring, you may be started with sample method designing and try to debug the timer job with below line
System.Diagnostics.Debugger.Break();
You may be wonder that you have copied the dll to GAC and did a IISRESET, and ran the sp timer job definition but the debugging engine of the VS 2010 never fires even after run the timer job.
I know your problem, Restart the "Sharepoint 2010 Timer" job and then start the IISRESET. ....magic appears.....there you get the debugger fires upon the timer running.
Happy coding,
Buddike
May be you are running with the time for creating Sharepoint timer job creation. You have started to create a feature with Event receivers, feature receivers and basic timer job class structure like below.
public class TimerJobClass : SPJobDefinition
{
//Your contructors to handle different combinations of parameters
public TimerJobClass()
{
}
public TimerJobClass(string jobName, SPService service, SPServer server, SPJobLockType targetType)
: base(jobName, service, server, targetType)
{
}
public TimerJobClass(string jobName, SPWebApplication webApplication, string targeturl)
: base(jobName, webApplication, null, SPJobLockType.Job)
{
this.Title = "Timer Job Name";
}
public override void Execute(Guid contentDbId)
{
//Things need to do.
}
}
After this structure declaring, you may be started with sample method designing and try to debug the timer job with below line
System.Diagnostics.Debugger.Break();
You may be wonder that you have copied the dll to GAC and did a IISRESET, and ran the sp timer job definition but the debugging engine of the VS 2010 never fires even after run the timer job.
I know your problem, Restart the "Sharepoint 2010 Timer" job and then start the IISRESET. ....magic appears.....there you get the debugger fires upon the timer running.
Happy coding,
Buddike
Subscribe to:
Posts (Atom)