Trying to use an SPWeb object that has been closed or disposed and is no longer valid.
when you use:
using(SPWeb oWeb= SPContext.Current.Web)
{
.....
}
this cause the error: Trying to use an SPWeb object that has been closed or disposed and is no longer valid.
the solution:
try
{
SPSite oSite=SPContext.Current.Site;
using(SPWeb oWeb=oSite.openWeb())
{
.....
}
}
using(SPWeb oWeb= SPContext.Current.Web)
{
.....
}
this cause the error: Trying to use an SPWeb object that has been closed or disposed and is no longer valid.
the solution:
try
{
SPSite oSite=SPContext.Current.Site;
using(SPWeb oWeb=oSite.openWeb())
{
.....
}
}
Comments
Post a Comment