Server Error in '/' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
   TheFA.ClubWembley.DataAccess.Repositories.GalleryRepository.GetLatestGalleries(Int32 maxGalleries, ID templateId) in C:\tfs\WembleyClub\CommonPipeline\Source\TheFA.ClubWembley.DataAccess\Repositories\GalleryRepository.cs:92
   TheFA.ClubWembley.Domain.ViewModelBuilder.Gallery.GalleryViewModelBuilder.GetLatestPhotos(Int32 max) in C:\tfs\WembleyClub\CommonPipeline\Source\TheFA.ClubWembley.Domain.ViewModelBuilder\Gallery\GalleryViewModelBuilder.cs:37
   TheFA.ClubWembley.Web.Areas.Gallery.Controllers.PhotoController.Index() in C:\tfs\WembleyClub\CommonPipeline\Source\TheFA.ClubWembley.Web\Areas\Gallery\Controllers\PhotoController.cs:20
   lambda_method(Closure , ControllerBase , Object[] ) +86
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +263
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +34
   System.Web.Mvc.<>c__DisplayClass13.<InvokeActionMethodWithFilters>b__10() +78
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +453
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +453
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +453
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +453
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +453
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +453
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +325