Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

object reference not set to an instance of an object.

Posted on by

Hello All,

I have custom entity .

i am calling a sdk update method to update the entity record but getting the object reference error.

serviceproxy.update(custom entity instance);

can anybody let me know what could this error be.

*This post is locked for comments

  • EmployeeOcta Profile Picture
    EmployeeOcta on at
    RE: object reference not set to an instance of an object.

    Hello Pawell,

    Below is the stacktrace that i am getting after the .Update method call.

    Server stack trace:

      at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)

      at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

      at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)

      at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)

      at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]:

      at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

      at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

      at Microsoft.Xrm.Sdk.IOrganizationService.Update(Entity entity)

      at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.UpdateCore(Entity entity)

      at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Update(Entity entity)

      at Microsoft.Xrm.Client.Services.OrganizationService.<>c__DisplayClass13.<Update>b__12(IOrganizationService s)

      at Microsoft.Xrm.Client.Services.OrganizationService.InnerOrganizationService.UsingService(Action`1 action)

      at Microsoft.Xrm.Client.Services.OrganizationService.Update(Entity entity)

      at Microsoft.Xrm.Client.Services.CachedOrganizationService.Update(Entity entity)

      at Microsoft.Xrm.Client.CrmOrganizationServiceContext.Update(Entity entity)

      at McGladrey.XrmConsoles.FormServiceDocumentUpdate.Program.UpdateEntity(Entity entity)

  • Vaneet Kumar Profile Picture
    Vaneet Kumar on at
    RE: object reference not set to an instance of an object.

    Can anyone try to answer this : community.dynamics.com/.../220435

  • Suggested answer
    shivaram Profile Picture
    shivaram 3,315 on at
    RE: object reference not set to an instance of an object.

    Are you trying to assign any option set value.??

    If yes,check your opinion set value limit once.

  • tw0sh3ds Profile Picture
    tw0sh3ds 5,600 on at
    RE: object reference not set to an instance of an object.

    Hi,

    This code is not helpful at all because we are looking for error in your specific code and you are pasting general idea for us, how then we can help you?

    Paste full stacktrace of the exception (I guess stacktrace are not restricted by your company...), currently we don't know if error is on your code side or is thrown by CRM because something else (for example a plugin on Update).

  • EmployeeOcta Profile Picture
    EmployeeOcta on at
    RE: object reference not set to an instance of an object.

    using (OrganizationServiceProxy objref=OrganizationServiceProxy())

    {

     Entity location =new Entity(new_CustomEntity)

    location.Attribute["x"]=some value;

    location.Attribute["y"]=some value;

    location.Attribute["z"]=some value;

    location.Attribute["p"]=some value;

    location.Attribute["q"]=some value;

    location.Attribute["r"]=some value;

    objref.Update(location)  // this line giving error . as object reference not set to an instance of an object.

    }

    I cannot put my code as i have restriction .

    So above is the high level idea which i have put in the code format.

    don't go each and every syntax missing or anything else as it is high level put forth.

    Now suggest me what is going to be wrong.

  • MaKeer Profile Picture
    MaKeer on at
    RE: object reference not set to an instance of an object.

    Post your code snippet, that will make lot easier for Forum members to suggest solutions

  • tw0sh3ds Profile Picture
    tw0sh3ds 5,600 on at
    RE: object reference not set to an instance of an object.

    Hi,

    You need to paste full code here, otherwise it's hard to help. Also are there any plugin on Update of this custom entity?

  • shivaram Profile Picture
    shivaram 3,315 on at
    RE: object reference not set to an instance of an object.

    Can you please tell me that, exactly in which line you are getting error? And paste here your update record code.

  • EmployeeOcta Profile Picture
    EmployeeOcta on at
    RE: object reference not set to an instance of an object.

    Hello Shivaram,

    I am getting the id in the entity , but i need to know is there any impact of the related entities as well??

  • EmployeeOcta Profile Picture
    EmployeeOcta on at
    RE: object reference not set to an instance of an object.

    Hello Alagu,

    Both the things are not null.

    Both are instantiated.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,104 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans