Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Steve Morgan 1291 posts 4307 karma points c-trib
    Jun 23, 2021 @ 10:23
    Steve Morgan
    0

    An object reference is required for the non-static field, method, or property 'MetaData.Current'

    An object reference is required for the non-static field, method, or property 'MetaData.Current'

    After updating a v7 site from v2.2.1 -> 2.2.5 I get this error - I'm sure it's something obvious but I'm drawing a blank!

    Steve

  • Richard Soeteman 3920 posts 12247 karma points MVP
    Jun 23, 2021 @ 10:25
    Richard Soeteman
    0

    Hi Steve,

    Do you have a call stack?

    Best,

    Richard

  • Steve Morgan 1291 posts 4307 karma points c-trib
    Jun 23, 2021 @ 10:39
    Steve Morgan
    0

    Here's what i have in the log. I haven't tried debugging it.

     2021-06-23 10:11:51,096 [P328/D2/T10] INFO  xxx.Core.Utilities.ExtensionMethods - Node: 1057 Exception: C:\data\repos\xxxx_v7\xxxx_v7\Views\Master.cshtml(20): error CS0120: An object reference is required for the non-static field, method, or property 'MetaData.Current' - StackTrace:    at System.Web.Compilation.AssemblyBuilder.Compile()
       at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
       at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
       at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
       at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
       at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
       at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
       at System.Web.WebPages.BuildManagerWrapper.CreateInstanceOfType[T](String virtualPath)
       at System.Web.WebPages.VirtualPathFactoryExtensions.CreateInstance[T](IVirtualPathFactory factory, String virtualPath)
       at System.Web.WebPages.VirtualPathFactoryManager.CreateInstanceOfType[T](String virtualPath)
       at System.Web.WebPages.VirtualPathFactoryExtensions.CreateInstance[T](IVirtualPathFactory factory, String virtualPath)
       at System.Web.WebPages.WebPageBase.CreatePageFromVirtualPath(String virtualPath, HttpContextBase httpContext, Func`2 virtualPathExists, DisplayModeProvider displayModeProvider, IDisplayMode displayMode)
       at System.Web.WebPages.WebPageBase.<>c__DisplayClass40_0.<RenderPageCore>b__0(TextWriter writer)
       at System.Web.WebPages.HelperResult.WriteTo(TextWriter writer)
       at System.Web.WebPages.WebPageBase.Write(HelperResult result)
       at System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body)
       at System.Web.WebPages.WebPageBase.PopContext()
       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
       at System.Web.WebPages.WebPageBase.<>c__DisplayClass40_0.<RenderPageCore>b__0(TextWriter writer)
       at System.Web.WebPages.HelperResult.WriteTo(TextWriter writer)
       at System.Web.WebPages.WebPageBase.Write(HelperResult result)
       at System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body)
       at System.Web.WebPages.WebPageBase.PopContext()
       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
       at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
       at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
       at Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer)
       at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_6.<BeginInvokeAction>b__4()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult)
    
  • Richard Soeteman 3920 posts 12247 karma points MVP
    Jun 23, 2021 @ 11:12
    Richard Soeteman
    0

    It comes from the view, how do you call the SEOChecker property?

  • Steve Morgan 1291 posts 4307 karma points c-trib
    Jun 23, 2021 @ 11:43
    Steve Morgan
    0

    Hi,

    In the master template whomever has set this up has just used

    @using SEOChecker.Library

    Then uses the static to output keywords etc... @MetaData.Current.Keywords

    When I update the nuget package this stops working. Can't see anything that's changed other than the SEOChecker code?

    What would be the recommended way to get the keywords etc?

  • Richard Soeteman 3920 posts 12247 karma points MVP
    Jun 23, 2021 @ 12:43
    Richard Soeteman
    100

    That should have gone wrong in the previous version as well.

    Syntax is

    @{
     var seo = Model.Value("your seochecker property alias") as SEOChecker.MVC.MetaData;
       }
    
     @seo.AllTags
    

    Hope this helps,

    Richard

  • Steve Morgan 1291 posts 4307 karma points c-trib
    Jun 23, 2021 @ 12:44
    Steve Morgan
    0

    Hi,

    Weird - I wonder if the dev has buried some static that I can't find that does this on start up... never mind - thanks for the response.

    Steve

Please Sign in or register to post replies

Write your reply to:

Draft