Pages

January 17, 2013

Digging on Could not find this Item error in SharePoint


I worked on this error a while ago when I was trying to replicate what was happening to a client's environment. When you want to upload EXE and DLL files to a document library in SharePoint using Explorer View, the operation fails with the following annoying error msg:

"Could not find this item
This is no longer located in \\sitename\DavWWWRoot. Verify the item's location and try again."

Of course uploading these types of files into SharePoint is highly not recommended due to security reasons, this is why they are on the blocked file types in Central Admin but for some companies it is a requirement.
You can find the complete error description and solution here, thanks to Stanislaw Delost!

But I wanted to see for myself what is the 'item' that is not being found as indicated by the error msg.
So, I built a small Windows program to imitate the exact operation of Explorer View's operation of copying the wanted files from a source folder into the desired doc library's WebDav folder.


And the error stack trace:

System.IO.FileNotFoundException was unhandled

  Message=Could not find file '\\dev\DavWWWroot\test\AERotatorWebpart.dll'.
  Source=mscorlib
  FileName=\\dev\DavWWWroot\test\AERotatorWebpart.dll
  StackTrace:
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
       at System.IO.File.Copy(String sourceFileName, String destFileName)


The code is simple. I used the program to copy normal document files and images and it worked just fine. When I used it to copy EXE and DLL files the program crashed. As you can see the exception msg in .NET is "Could not find file "\\ServerName\DavWWWroor\DocLibName\FileName.DLL"
and the exception is of type FileNotFoundException.
It looks like that it couldn't find the file that we want to copy in the first place..weird!!

Explorer View operation uses WebDav protocol and agents that get installed with SharePoint.
When WebDav detects a file of type .EXE or .DLL, it runs 2 handlers in IIS: CGI-exe (for EXE files), and ISAPI-dll (for DLL files). My guess is that these programs are trying to access our files from the doc lib folder (destination) before the copying operation completed, so it will not find the file and an error occurs. 

As mentioned in details in Delost's blog, the solution is to prevent the CGI-exe and ISAPI-dll handlers from running in IIS by removing the EXECUTE permission in Hanlder Mappings in IIS.









1 comment:

  1. One of the common error messages is 'could not find this item'
    It can be easily fix. Use “LongPathTool” guaranteed fix for your problem.

    ReplyDelete