Cannot perform runtime binding on a null reference
I have a Macro that I've used on several sites. I built it in my core site that I base all other sites on. I just returned to that site to do some other development and noticed the main menu is not working.
I get this error:
Cannot perform runtime binding on a null reference at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at ASP._Page_Views_MacroPartials__Navigation_cshtml.Execute() in [snip]\MacroPartials\_Navigation.cshtml:line 39
Here is the code:
@if (nav != null) { <nav class="@nav.GetPropertyValue("Navigation CSS Class ")"> <ul> @foreach (IPublishedContent item in nav.Children()) { if (item.HasValue("Link")) { try { IPublishedContent link = item.GetPropertyValue<IPublishedContent>("Link");
I'm not sure if this is the case here, but I've seen cases like this where the line being reported in not actually the one causing the error. Can you check that your "link" object is not null? It doesn't seem likely that the "item" object would be.
Cannot perform runtime binding on a null reference
I have a Macro that I've used on several sites. I built it in my core site that I base all other sites on. I just returned to that site to do some other development and noticed the main menu is not working.
I get this error:
Here is the code:
This is the line that fails:
This is currently working fine on five other websites and was working on this one until I returned to it today.
I have no idea what's causing the error, can anyone help?
Jon
Hi Jon -
I'm not sure if this is the case here, but I've seen cases like this where the line being reported in not actually the one causing the error. Can you check that your "link" object is not null? It doesn't seem likely that the "item" object would be.
Thanks.
Barry
is working on a reply...