jgauffin / griffin.mvccontrib

A contribution project for ASP.NET MVC3
http://blog.gauffin.org/tag/griffin-mvccontrib/
GNU Lesser General Public License v3.0
83 stars 40 forks source link

System.Web.Mvc.CompareAttribute - NullReferenceException was unhandles by user code. #6

Closed tommiller85 closed 12 years ago

tommiller85 commented 12 years ago

I get the following problem when trying to use the System.Web.Mvc.Compare attribute on my model.

Object reference not set to an instance of an object.

Call stack location:

Griffin.MvcContrib.DLL!Griffin.MvcContrib.Localization.LocalizationModelValidatorProvider.MyValidator.Validate() Line 194 + 0x35 bytes

Source file information:

Locating source for 'D:\Tfs\External\griffin.mvccontrib\griffin.mvccontrib\source\Griffin.MvcContrib\Localization\LocalizedModelValidatorProvider.cs'. Checksum: MD5 {a4 85 85 22 c3 89 75 c4 a7 85 35 77 1e a4 29 1f} The file 'D:\Tfs\External\griffin.mvccontrib\griffin.mvccontrib\source\Griffin.MvcContrib\Localization\LocalizedModelValidatorProvider.cs' does not exist. Looking in script documents for 'D:\Tfs\External\griffin.mvccontrib\griffin.mvccontrib\source\Griffin.MvcContrib\Localization\LocalizedModelValidatorProvider.cs'... Looking in the projects for 'D:\Tfs\External\griffin.mvccontrib\griffin.mvccontrib\source\Griffin.MvcContrib\Localization\LocalizedModelValidatorProvider.cs'. The file was not found in a project. Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\'... Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\'... Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\atl\'... Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\'... The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: D:\Tfs\External\griffin.mvccontrib\griffin.mvccontrib\source\Griffin.MvcContrib\Localization\LocalizedModelValidatorProvider.cs. The debugger could not locate the source file 'D:\Tfs\External\griffin.mvccontrib\griffin.mvccontrib\source\Griffin.MvcContrib\Localization\LocalizedModelValidatorProvider.cs'.

eSaw commented 12 years ago

What was the resolution?

I get the same with latest version:

NullReferenceException: Object reference not set to an instance of an object.] Griffin.MvcContrib.SqlServer.Localization.SqlLocalizedTypesRepository.GetPrompt(CultureInfo culture, TypePromptKey key) in D:\Tfs\External\griffin.mvccontrib\griffin.mvccontrib\source\Griffin.MvcContrib.SqlServer\Localization\SqlLocalizedTypesRepository.cs:106 Griffin.MvcContrib.Localization.Types.RepositoryStringProvider.Translate(Type type, String name) +357 Griffin.MvcContrib.Localization.Types.RepositoryStringProvider.GetModelString(Type model, String propertyName) +42 Griffin.MvcContrib.Localization.LocalizedModelMetadataProvider.Translate(Type type, String propertyName) +52 Griffin.MvcContrib.Localization.LocalizedModelMetadataProvider.CreateMetadata(IEnumerable1 attributes, Type containerType, Func1 modelAccessor, Type modelType, String propertyName) +143 System.Web.Mvc.AssociatedMetadataProvider.GetMetadataForProperty(Func1 modelAccessor, Type containerType, PropertyDescriptor propertyDescriptor) +93 System.Web.Mvc.<GetMetadataForPropertiesImpl>d__2.MoveNext() +226 System.Linq.Buffer1..ctor(IEnumerable1 source) +217 System.Linq.<GetEnumerator>d__0.MoveNext() +96 System.Linq.WhereSelectEnumerableIterator2.MoveNext() +87 System.Collections.Generic.List1..ctor(IEnumerable1 collection) +327 System.Linq.Enumerable.ToList(IEnumerable1 source) +58 Kendo.Mvc.UI.ModelDescriptor.Translate(ModelMetadata metadata) +143 Kendo.Mvc.UI.ModelDescriptor..ctor(Type modelType) +123 Kendo.Mvc.UI.DataSource.ModelType(Type modelType) +62 Kendo.Mvc.UI.Grid1..ctor(ViewContext viewContext, IJavaScriptInitializer initializer, IUrlGenerator urlGenerator, ILocalizationService localizationService, IGridHtmlBuilderFactory htmlBuilderFactory) +1504 Kendo.Mvc.UI.ViewComponentFactory.Grid() +245 Kendo.Mvc.UI.ViewComponentFactory.Grid(IEnumerable1 dataSource) +95 ASP._Page_Areas_razor_Views_web_grid_index_cshtml.Execute() in c:\Users\djones.INTEGRATION\Documents\Visual Studio 2010\Projects\Peer2Peer\Areas\razor\Views\web\grid\index.cshtml:13 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81 System.Web.WebPages.StartPage.RunPage() +19 System.Web.WebPages.StartPage.ExecutePageHierarchy() +65 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76 System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220 System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13 System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 continuation) +260 System.Web.Mvc.<>cDisplayClass1e.b1b() +19 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 continuation) +260 System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult) +177 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343 System.Web.Mvc.Controller.ExecuteCore() +116 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10 System.Web.Mvc.<>cDisplayClassb.b5() +37 System.Web.Mvc.Async.<>cDisplayClass1.b0() +21 System.Web.Mvc.Async.<>cDisplayClass8`1.b7(IAsyncResult _) +12 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62 System.Web.Mvc.<>cDisplayClasse.bd() +50 System.Web.Mvc.SecurityUtil.b__0(Action f) +7 System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970061 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

jgauffin commented 12 years ago

Yeah, I can reproduce it but can't figure out why.

eSaw commented 12 years ago

Jonas,

While I have copied your application start - with a few neccesary chages i.e database name to my global.asax and followed all other steps as laid out I receive this error.

Failed to find an 'ILocalizedStringProvider' implementation. Either include one in the LocalizedModelMetadataProvider constructor, or register an implementation in your Inversion Of Control container.

Any help greatly appreciated.

On Tue, Aug 14, 2012 at 3:24 AM, Jonas Gauffin notifications@github.comwrote:

Yeah, I can reproduce it but can't figure out why.

— Reply to this email directly or view it on GitHubhttps://github.com/jgauffin/griffin.mvccontrib/issues/6#issuecomment-7721925.

oislek commented 12 years ago

Hi Jonas,

I am experiencing the same issue with @eSaw (see above) Also the last line of the code segment I placed in Application_start had to change as: ModelValidatorProviders.Providers.Add(new LocalizedModelValidatorProvider());

Thank you for your contributions,

jgauffin commented 12 years ago

Have you tried with the lastest packages?

jgauffin commented 12 years ago

Closed due to lack of response