locked
Silverlight Grid Error CRM 2013 online -Cannot perform runtime binding on a null reference RRS feed

  • Question

  • Hi,

    Our customer has got an online trial instance for CRM 2013 set up. we had built a Silverlight Grid for revenue forecasting purpose on opportunity entity form last year, which was working fine in CRM 2011 but since 2013 they are experiencing following error on opportunity form load:

    CrmScriptErrorReport>
      <ReportVersion>1.0</ReportVersion>
      <ScriptErrorDetails>
       <Message>Unhandled Error in Silverlight Application Cannot perform runtime binding on a null reference   at CallSite.Target(Closure , CallSite , Object )

    Upon debugging I found the code is failing when initially trying to retrieve CRM field values(_StartDate) using Dynamic object because for some bizarre reason dynamicPage object appears null. Same code is working perfectly for last 1 year in customer's production environment ( CRM 2011 online ).

     ScriptObject xrm = (ScriptObject)HtmlPage.Window.GetProperty("Xrm");
                ScriptObject page = (ScriptObject)xrm.GetProperty("Page");
                dynamic dynamicPage = page;
    
                dynamic _startDate = dynamicPage.data.entity.attributes.get(ServerUtility.GetStartDateFieldName()).getValue();

    If I clear the browser cache I get rid of error but then we loose any changed data on form. We are using IE 10. we have also tried the same on IE 8 but same problem happens.

    Interestingly when I put alert before retrieving CRM field value, the problem of dynamicPage being  null disappears but then the annoying thing is user has to click ok every time form loads/refreshes.

    we have also raised with issue with Microsoft and they have assigned an escalation Engineer but so far no luck!

    Any ideas please?

    Thanks

    Umer

    Tuesday, February 4, 2014 2:20 PM

Answers

  • I think the real answer here at this point is to probably stop using Silverlight and use jscript webresources with WebAPI
    Tuesday, August 23, 2016 4:16 PM
    Moderator

All replies

  • _StartDate is not a valid fieldname.  If you are looking at ID's and such it could be a problem.  How are you trying to access your fields.  I think we need the code for your 
    ServerUtility.GetStartDateFieldName()).getValue()

    Jamie Miley

    Check out RBA Today!

    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!

    Tuesday, February 4, 2014 3:20 PM
    Moderator
  • Thanks for your response Jamie, following is the code. The parameters are passed from Silverlight Grid web resource.

     public static string GetStartDateFieldName()
            {
                object val = GetParameterByName("StartDateFieldName");
                if (val != null)
                {
                    return val.ToString();
                }
    
                return "nttdata_projecteststartdate";
            }
    
     public static string GetParameterByName(string propName)
            {
                string data = "";
    
                if (App.Current.Host.InitParams.ContainsKey("data"))
                {
                    data = App.Current.Host.InitParams["data"];
                }
    
                foreach (string frag in data.Split(';'))
                {
                    if (frag.StartsWith(propName + "="))
                    {
                        return frag.Substring(propName.Length + 1);
                    }
                }
    
                return null;
            }
    

    Tuesday, February 4, 2014 3:46 PM
  • Did you manage to resolve this?  I'm having the same issue
    Monday, April 11, 2016 1:50 PM
  • I think the real answer here at this point is to probably stop using Silverlight and use jscript webresources with WebAPI
    Tuesday, August 23, 2016 4:16 PM
    Moderator