Null reference in File management / Global Files / VersioningFileSummary

Vote:
 

When I try to open Global Files in File management Action Window I get a System.NullReferenceException on EPiServer.Web.Hosting.Versioning.VersioningFileSummary..ctor(FileItem file, FileOperations fileOp).

My setup is two servers with EPiServer 5.2.375.133 installed. Both joined to same domain. VPP files are stored on a third server in the same domain. AppDomain user is a domain account with modify permissions on the fileshare. Both servers use the same database. Remote events are configured for cache invalidation.

All worked fine until yesterday. The problem started after I uploaded an image, cropped it and saved it with a new name and then deleted the new cropped file. During the delete operation/request there was some kind of performance related problem within the environment. After the delete operation I always get the exception described above when I try to browse Global Files in File management. The VPP for Global Files is a EPiServer.Web.Hosting.VirtualPathVersioningProvider with default configuration.

The uploaded file and the cropped file still exist on the fileshare. The filename of the files also exists in the tblItems table, but the pkID is not the same as the guid on the fileshare. When viewing the site in viewmode, images from global files can be viewed.

There seams to be one or two files miss referenced in the VPP. Anyone knows how to fix this? And should this ever happen?

#29461
Apr 28, 2009 11:23
Vote:
 

Hi Marthin, were you able to resolve this issue because I am also facing a similar issue?

#49018
Edited, Feb 28, 2011 18:04
Vote:
 

I have had a simular issue once. It was some files in the VPP that was created, but didn't exists.

I used this code to fix the problem

        protected void Button12_Click(object sender, EventArgs e)
        {
            StartIndexOnItemLit.Text = "";
             StringBuilder builder=new StringBuilder();
             VirtualPathHandler instance = VirtualPathHandler.Instance;
                
            foreach (var a in VirtualPathHandler.Instance.VirtualPathProviders.Keys)
            {
                if (a is VirtualPathUnifiedProvider)
                {

                    var dir = instance.GetDirectory((a as VirtualPathUnifiedProvider).VirtualPathRoot, true);

                    foreach (var element in dir.Children)
                    {
                        CheckItem(builder, element);
                    }
                }

            }
            StartIndexOnItemLit.Text="<ul>"+builder.ToString()+"</ul>";
            // Itera.Cms5Provider.AddToIndexer.Current.AddToIndex(StartIndexOnItem.Text, true, false);
        }

        private void CheckItem(StringBuilder builder, object element)
        {
            if (element is UnifiedDirectory)
            {
                CheckDir((element as UnifiedDirectory), builder);
            }
            if (element is UnifiedFile)
            {
                CheckFil((element as UnifiedFile), builder);
            }
        }
        void CheckDir(UnifiedDirectory dir, StringBuilder builder)
        {
            try
            {
                builder.AppendLine("<ul>");
                foreach (var a in dir.Children)
                {
                    CheckItem(builder, a);
                }
                builder.AppendLine("</ul>");
            }
            catch (System.Exception error)
            {
                builder.AppendLine(dir.Name+" "+dir.VirtualPath+" "+error.Message+" "+error.StackTrace);
            }
        }
        void CheckFil(UnifiedFile fil,StringBuilder builder)
        {
            try
            {
                var a = fil.Summary;
            }
            catch (Exception error)
            {
                
                builder.AppendLine("<li>deleting file since source don't exists " + fil.VirtualPath + "</li>");
                fil.Delete();
            }
        }

    

#49019
Feb 28, 2011 21:36
Vote:
 

Awesome! I had the exact same problem with the VersioningFileSummary nullreference. This code helped me resolving this issue, thank you.

#49194
Mar 09, 2011 9:33
Vote:
 

you are welcome. Took myself some time to understand why. In my case it was a FileCreate event that throw an error

#49220
Mar 09, 2011 12:16
Vote:
 

Good work Anders. This saved me alot of time. Thanks.

#55857
Dec 21, 2011 9:30
Vote:
 

Thanks, happy that I could be of help :)

#55859
Dec 21, 2011 10:10
Ted
Vote:
 

Anders, thanks a lot for sharing this! Saved me a lot of (unnecessary) work! :) Cheers!

#65400
Jan 29, 2013 10:24
Vote:
 

Hi Anders,

I got a similar error but I wonder if you could explaon some more abput where you use the code you posted?

Best regards,

Carl

#66017
Feb 18, 2013 15:27
Ted
Vote:
 

Carl, in my case I added an admin plugin with a button - and then added an event handler for that button's click event to execute Anders' code.

 

he reason for the inconsistencies in my case was that I was trying to set file properties before I had written data to the file.

#66019
Feb 18, 2013 15:49
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.