views:

306

answers:

1

I am having the weirdest error.

If anyone can give me hints, I've found nothing relevant with Google.

When I hook the events on ItemCheckingOut on a Document Library (TemplateType=101) with 6 items inside, properties.ListItem will always be null for all those items.

This never happened before. The problem seem related to the fact that those files are deployed in Feature with WSS Extensions 1.2.

Here is what I have done:

  • If I try to access the list and get the items manually, the count return 0.
  • If I try to get the file manually (even though sharepoint say it doesn't exist), I can't make any operation on it (OpenBinary in this case) and it will throw.
  • Creating a new file that is not deployed by feature inside the same list make the "properties.ListItem" not null again for this specific element only.

Anyone have an idea?

+2  A: 

Everything points to the files not being correctly deployed to the list. I'd double-check how you're specifying the files in the feature. (Note: you can successfully get an SPFile object for a file which does not exist! That's what your observation in your second bullet point shows). Is the type in the elements.xml file specified as GhostableInLibrary?

Yuliy
Bravo! That was actually it! I figured it out the same day I asked the question but wanted to know if StackOverflow was still working! Files that are deployed without "GhostableInLibrary" do not appear in a list. It is also important to note that when declaring your File Element inside the Element Manifest file, you must NOT have any "/" inside the "Url" attribute. Otherwise, it won't be included inside the list either.Congratz!
Maxim