NullReferenceException logged

Aug 16, 2011 at 11:07 AM

Firstly, thanks for this module, it seems to work really well. The site is working perfectly, but we are seeing the following error a lot in our log files:

NullReferenceException thrown from IContentHandler by Contrib.MediaFolder.Handlers.RemoteStorageSettingsPartHandler

System.NullReferenceException: Object reference not set to an instance of an object. at Contrib.MediaFolder.Handlers.RemoteStorageSettingsPartHandler.<>c__DisplayClass2.<.ctor>b__0(InitializingContentContext context, RemoteStorageSettingsPart part) at Orchard.ContentManagement.Handlers.ContentHandler.InlineStorageFilter`1.Initializing(InitializingContentContext context, TPart instance) in d:\TeamCity\Projects\Orchard-Default\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 116 at Orchard.ContentManagement.Handlers.StorageFilterBase`1.Orchard.ContentManagement.Handlers.IContentStorageFilter.Initializing(InitializingContentContext context) in d:\TeamCity\Projects\Orchard-Default\src\Orchard\ContentManagement\Handlers\StorageFilterBase.cs:line 28 at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.Initializing(InitializingContentContext context) in d:\TeamCity\Projects\Orchard-Default\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 198 at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass6.<New>b__5(IContentHandler handler) in d:\TeamCity\Projects\Orchard-Default\src\Orchard\ContentManagement\DefaultContentManager.cs:line 94 at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in d:\TeamCity\Projects\Orchard-Default\src\Orchard\InvokeExtensions.cs:line 19

 

If I modify the RemoteStorageSettingsPartHandler like so then the error does not occur:

 

OnInitializing<RemoteStorageSettingsPart>(
                (context, part) => {
                    //part.Record.MediaLocation =
                    //    workContextAccessor.GetContext().HttpContext.Server.MapPath("~/Media");
                });


This doesn't seem to have any visible side effects, but I am assuming that the purpose of this code is to pre-populate the record with Orchards default media path.