locked
Unknown number prefix specified RRS feed

  • Question

  • I'm trying to update an Opportunity using the REST endpoint in Silverlight, but I get an exception with the message "unexpected number prefix specified".  Can anyone explain what this means, what causes it and how to prevent it?
    Friday, May 11, 2012 9:25 AM

Answers

  • I had missed a couple of points from this page when setting up my Silverlight project:

    In the service reference, edit the Reference.cs file. Replace each instance of “: global::System.ComponentModel.INotifyPropertyChanged” with “: ODataEntity, global::System.ComponentModel.INotifyPropertyChanged”. You will find this text for every entity in your organization.

    and:

    You must set the DataServiceContext.IgnoreMissingProperties property to true after you instantiate your DataServiceContext.

    Without this property set, an error occurs if new entities or attributes are created in Microsoft Dynamics CRM after you generate your service reference.

    I think the first of these fixed the problem

    • Edited by StevieB Friday, May 11, 2012 11:07 AM
    • Marked as answer by StevieB Friday, May 11, 2012 11:07 AM
    Friday, May 11, 2012 11:06 AM

All replies

  • Are you able to debug your silverlight application and get some more error details ?

    Mahain : Check My Blog
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.


    Friday, May 11, 2012 9:45 AM
    Moderator
  • I have debugged, but that is as much detail as I can get.  The exception happens when I try to do

    _context.EndSaveChanges(result);
    The opportunity object in 'result' looks to be as I would expect.
    Friday, May 11, 2012 9:52 AM
  • Could you share your code here

    Mahain : Check My Blog
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Friday, May 11, 2012 9:56 AM
    Moderator
  • Hi StevieB,

    When you encounter an error like this in Silverlight, the best way to know exactly what's going on under the hood is to use a program called Fiddler.

    With Fiddler, you can see what the actual error response returned from CRM and definitely a great tool to help debugging your code.

    Make sure you double check that your entity attribute names in Silverlight matches the one in CRM. Usually that's the cause of this error.

    Hope this helps.


    Dimaz Pramudya - CRM Developer - CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits

    Friday, May 11, 2012 10:03 AM
  • private void update()
    {
      Opportunity upd = new Opportunity();
      upd.OpportunityId = new Guid(passedInGUID);
      upd.CustomerId = OppCustomerId; //read from record before update
      upd.mx_CommercialStrategy = "testing";
                    
      _context.AddToOpportunitySet(upd);
      _context.BeginSaveChanges(OnUpdateProspectComplete, upd);
    }
                    
    private void OnUpdateProspectComplete(IAsyncResult result)
    {
      try
      {
        _context.EndSaveChanges(result);
        Opportunity updatedProspect = result.AsyncState as Opportunity;
        MessagePanel.Children.Add(new TextBlock()
        {
          Text =
            String.Format("The prospect was updated and strategy set to \"{0}\".",
                          updatedProspect.mx_CommercialStrategy)
          });
    
          _syncContext.Send(new SendOrPostCallback(setBusy), false);
        }
        catch (SystemException se)
        {
          _syncContext.Send(new SendOrPostCallback(showErrorDetails), se);
        }
    }
    I have tried replacing the line "AddToOpportunitySet" with:
    _context.AttachTo("OpportunitySet",upd);
    _context.UpdateObject(upd);
    but that give the even more helpful message "an unexpected error has occurred"
    Friday, May 11, 2012 10:15 AM
  • I had missed a couple of points from this page when setting up my Silverlight project:

    In the service reference, edit the Reference.cs file. Replace each instance of “: global::System.ComponentModel.INotifyPropertyChanged” with “: ODataEntity, global::System.ComponentModel.INotifyPropertyChanged”. You will find this text for every entity in your organization.

    and:

    You must set the DataServiceContext.IgnoreMissingProperties property to true after you instantiate your DataServiceContext.

    Without this property set, an error occurs if new entities or attributes are created in Microsoft Dynamics CRM after you generate your service reference.

    I think the first of these fixed the problem

    • Edited by StevieB Friday, May 11, 2012 11:07 AM
    • Marked as answer by StevieB Friday, May 11, 2012 11:07 AM
    Friday, May 11, 2012 11:06 AM