Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, April 21, 2014 9:17 AM
I m getting this error on page load of visual webpart added to the sharepoint site.What could be the issue??I m getting this error like in dev and not in test environment..What could be the issue and how do i fix it..
System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
at abc.abc.abc.abc()
at abc.abc.abc.Page_Load(Object sender, EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
All replies (9)
Monday, April 21, 2014 9:39 AM
Hello.
Its pretty simple.
Please check if the publishing feature is activated or not. If not, please enable them at sitecollection and site level :-)
Let me know the outcome!!
Monday, April 21, 2014 9:42 AM
Hi!
Look deeper into ULS log - it may be stated what concrete file is missing.
Monday, April 21, 2014 9:51 AM
The error message clearly mentions that some file which the page load is looking for is not found. Not sure how you have written your code on page load, but a hint would be to check thru the code and see for example if you are specifying some path for log file and it is not available or some reference you are using and it is not available. Also check if your usercontrol file is available in 14 hive.
Monday, April 21, 2014 10:52 AM
I can find one more log which is related to the webpart...All features are activated..This error is occuring only some times and not everytime this occurs on submit of infopath form to form library where we have a webpart added to the page which performs functionality onload of the page
System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002), StackTrace:
at Microsoft.SharePoint.SPWeb.GetFileOrFolderProperties(String strUrl, ListDocsFlags listDocsFlags, Boolean throwException, SPBasePermissions& permMask)
at Microsoft.SharePoint.SPFile.PropertiesCore(Boolean throwException)
at Microsoft.SharePoint.SPFile.get_CheckOutType()
at abc.abc.abc.abc()
at abc.abc.abc.Page_Load(Object sender, EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)
at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
Monday, April 21, 2014 10:54 AM
I guess abc.abc.abc.abc() is your function. So it calls SPFile.get_CheckOut() on page loading and it is the place where you have to search for an error.
Monday, April 21, 2014 11:29 AM
Please find the code i am using and let me know if there is anything wrong with it
public partial class TestLinks: WebPart
{
//Properties window customized to change the List GUID and apply to the page
[WebBrowsable(true), Personalizable(true), Category("ListPart"), DisplayName("ListGUID."), WebDisplayName("ListGUID"), WebDescription("Enter List GUID")]
public string Property1
{
get { return _property1; }
set { _property1 = value; }
}
string _property1;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
InitializeControl();
}
protected void Page_Load(object sender, EventArgs e)
{
// functionality to work on pageload
abc();
}
private void abc()
{
try
{
if (_property1 != null)
{
string currentSiteUrl = SPContext.Current.Web.Url;
using (SPSite site = new SPSite(currentSiteUrl))
{
using (SPWeb spWeb = site.OpenWeb())
{
//Set property to the list
spWeb.AllowUnsafeUpdates = true;
SPList spList = spWeb.Lists[new Guid(_property1)];
if (spList != null)
{
SPQuery spquery = new SPQuery();
//query.Query = "<Query><Where><IsNull><FieldRef Name='CheckoutUser' /></IsNull></Where><OrderBy><FieldRef Name='Modified' Ascending='False' /></OrderBy></Query>";
//query.Query = "<Where><And><IsNull><FieldRef Name='CheckoutUser' /></IsNull><Eq><FieldRef Name='Status' /><Value Type='Choice'>In Progress</Value></Eq></And></Where>";
//query.Query = "<Query><Where><IsNull><FieldRef Name='CheckoutUser' /></IsNull></Where></Query>";
spquery.Query = "<Where>" +
"<IsNull>" +
"<FieldRef Name='CheckoutUser' />" +
"</IsNull>" +
"</Where>";
//spquery.Query = "<Where><And><IsNull><FieldRef Name='CheckoutUser' /></IsNull><Eq><FieldRef Name='Status' /><Value Type='Choice'>In Progress</Value></Eq></And></Where>";
SPListItemCollection items = spList.GetItems(spquery);
{
if (items.Count > 0)
{
foreach (SPListItem spItem in items) //loop through the list items
{
if (spItem != null)
{
SPFile objfile = spItem.File;
if (objfile != null)
{
if (spItem.File.CheckOutType == SPFile.SPCheckOutType.None && spItem["Status"] != null && Convert.ToString(spItem["Status"]) == "In Progress")
{
if (spItem["TemplateUrl"] != null)
{
if (spItem["TemplateUrl"].ToString() != string.Empty)
{
string strTemplateLink = spItem["TemplateUrl"].ToString();
if (!string.IsNullOrEmpty(strTemplateLink))
{
string[] str = strTemplateLink.Split('/');
if (strTemplateLink.Contains("http") || strTemplateLink.Contains("https"))
{
spItem["TemplateUrl"] = "~sitecollection/FormServerTemplates/" + str[str.Length - 1].ToString();
spItem.SystemUpdate();
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
Monday, April 21, 2014 11:34 AM
Here:
if (objfile != null) {
if (spItem.File.CheckOutType == SPFile.SPCheckOutType.None && spItem["Status"] != null && Convert.ToString(spItem["Status"]) == "In Progress")
Error occurs during invocation of spItem.File.CheckOutType
Monday, April 21, 2014 11:50 AM
How do i fix it...Can you help me in fixing the solution
Monday, August 25, 2014 2:58 AM
Hi,
The sPItem.File.checkouttype could be null for some records and that could be the reason for the null reference exception.
Check for the spItem.file.checkouttype separately and then perform other conditions.
For eg:
if (objfile != null)
{
if (spItem.File.CheckOutType == SPFile.SPCheckOutType.None)
{
if (spItem["Status"] != null && Convert.ToString(spItem["Status"]) == "In Progress")
{
}
else
{
//write your else conditions here
}
}
Hope this helps...