locked
How to use LINQ Provider in class library to create Dynamics CRM 2011 Plug-in? RRS feed

  • Question

  • Hello All,

    I am creating a plug-in for Dynamics CRM 2011 that will select data from  one entity and will insert that data to another value. I have explored sdk but did not find anything useful. I need your guidance.  Can you please provide me link for any useful tutorial or tell me about steps to use LINQ in Plugins.

    Thanks in advance.


    -- NMathur
    • Edited by nmathur Monday, March 12, 2012 9:50 AM
    Wednesday, January 11, 2012 10:32 AM

Answers

  • Hello Sam and JayB,

    I am very thankful to both of you for your help. Today i have search more on web for "LINQ Provider for custom entity in dynamics crm 2011" and find a code on code project and followed its steps to create class library (Which did not includes Microsoft.Xrm.Client.dll) :

    http://www.codeproject.com/KB/cs/AutonumberingCRM2011.aspx#xx3890834xx

    My code is now working without any exception. But one thing is not clear to me that way its Early Bound Types cs class does not require Microsoft.Xrm.Client.dll (because my class required Microsoft.Xrm.Client.dll).

    Please review that article and guide me about this issue.

    Thanks again :)

     


    -- NMathur
    • Marked as answer by nmathur Thursday, January 12, 2012 7:05 AM
    Thursday, January 12, 2012 7:03 AM

All replies

  • You can start with downloading the latest SDK http://www.microsoft.com/download/en/details.aspx?id=24004

    This version has VS framework available that makes coding easier. You can read more about this on the following blog post http://inogic.blogspot.com/2011/11/crm-2011-developer-toolkit.html

    You need to generate the classes using crmsvcutil and include this in your plugin project.

    Here is another post http://crmconsultancy.wordpress.com/2011/06/06/using-linq-in-crm-2011-plugins/ that explains LINQ in plugins.

    HTH

    Sam

     


    Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Wednesday, January 11, 2012 10:58 AM
  • Hi Sam,

    Thanks for reply, I tried all links provided by you and created a sample plugin for account creation but I am receving following error:

    System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Xrm.Client, Version=5.0.9688.1154, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified

    Please reply if you or anyone else can help me about this issue.

    Thanks,
    -- NMathur
    Wednesday, January 11, 2012 12:16 PM
  • You should find this assembly in the sdk that you have downloaded.

    You need to add a reference to this assembly in your project.

    HTH

    Sam


    Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Wednesday, January 11, 2012 12:37 PM
  • Hi Sam,

    That is the problem, I already added a reference to this assembly. Here is screen-shot for all references in my plugin:

    Please tell me if anything is missing or wrong.

    Thanks in advance.

     


    -- NMathur

    • Edited by nmathur Wednesday, January 11, 2012 2:01 PM
    Wednesday, January 11, 2012 12:44 PM
  • do u get this error at the time of compiling/building the project or after deploying it in CRM?

    Are you using .NET framework 4.0?

    Sam


    Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"


    • Edited by Sam - Inogic Wednesday, January 11, 2012 12:54 PM
    Wednesday, January 11, 2012 12:53 PM
  • I received this error after deploying it in CRM. Plugin was successfully registered to CRM. Yes I am using .NET framework 4.0 .

     


    -- NMathur
    • Edited by nmathur Wednesday, January 11, 2012 2:02 PM
    Wednesday, January 11, 2012 1:56 PM
  • Add the assembly to GAC on CRM server.

    Did you register the plugin to Disk or Database?

    Sam


    Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Wednesday, January 11, 2012 1:57 PM
  • Ok I will try that. I have registered plugin to Database.

    -- NMathur
    Wednesday, January 11, 2012 4:42 PM
  • If your install is on Premise check the version of the Microsoft.Xrm.Sdk.dll you registered vs. the one on the CrmServer at:

    Z:\Program Files\Microsoft Dynamics CRM\Server\bin

    They need to be the same version.

    -JayB

    Wednesday, January 11, 2012 4:42 PM
  • Hi JayB,

    I need to register mu plugin for both crm online and crm on-premise. I have checked the versions for Microsoft.Xrm.Sdk.dll on my sdk and on my crm server, both are different.

    sdk version is:  5.0.9688.1155, and

    crm onpremise is:  5.0.9688.1533

    Now I will try SDK of version 5.0.9688.1533 (Sam has provided me link for that). But what about crm online, can you please provide me any solution for that.

    And can anyone please provide me any working sample code or any tutorial, I really need that.

    Thanks in advance.


    -- NMathur
    • Edited by nmathur Thursday, January 12, 2012 4:27 AM
    Thursday, January 12, 2012 4:18 AM
  • Hi Jay,

    I tried new sdk, but I am still getting same error (only assambly version is different this time):

    Could not load file or assembly 'Microsoft.Xrm.Client, Version=5.0.9688.1533, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

    What should I do?


    -- NMathur
    Thursday, January 12, 2012 4:47 AM
  • Generally the same dll works for both Online and On-Premise solution.

    Can you confirm the CRM On-Premise version... What rollups are installed?

    Sam


    Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Thursday, January 12, 2012 6:33 AM
  • Hello Sam and JayB,

    I am very thankful to both of you for your help. Today i have search more on web for "LINQ Provider for custom entity in dynamics crm 2011" and find a code on code project and followed its steps to create class library (Which did not includes Microsoft.Xrm.Client.dll) :

    http://www.codeproject.com/KB/cs/AutonumberingCRM2011.aspx#xx3890834xx

    My code is now working without any exception. But one thing is not clear to me that way its Early Bound Types cs class does not require Microsoft.Xrm.Client.dll (because my class required Microsoft.Xrm.Client.dll).

    Please review that article and guide me about this issue.

    Thanks again :)

     


    -- NMathur
    • Marked as answer by nmathur Thursday, January 12, 2012 7:05 AM
    Thursday, January 12, 2012 7:03 AM