locked
Annotation Class - Goin Nuts! RRS feed

  • Question

  • I am trying to code a CRM 2011 Plugin that works with annotations.


    I am looking at an MSDN sample showing how to work with annotations but I can't reference the Annotation class!

    I have a simple line of code:

    Annotation note = new Annotation();

    But I get the error:

    The type or namespace name 'Annotation' could not be found (are you missing a using directive or an assembly reference?)

    I've added the references:

    using Microsoft.Xrm.Sdk;

    using Microsoft.Xrm.Sdk.Client;

    using Microsoft.Xrm.Sdk.Query;

    but the reference can't be found to annotation!!  Where is annotation?  (And why does this page not clearly define where to get the reference from???: http://msdn.microsoft.com/en-us/library/gg334398.aspx)

    Monday, August 29, 2011 8:10 PM

Answers

All replies

  • Hi Karl,

    Try this:

    - Download the CRM 2011 SDK if you haven't already: http://www.microsoft.com/download/en/details.aspx?id=24004

    - Extract the SDK, and navigate to: sdk\samplecode\cs\generalprogramming\earlybound

    - Open basicoperations.csproj

    - Type Annotation note = new Annotation(); into any of of the .cs files.

    If you right-click Annotation and choose "Go to definition", you'll see that it's defined in a file called MyOrganizationCrmSdkTypes.cs

    The code generation tool that creates "MyOrganizationCrmSdkTypes.cs" is referenced in this SDK article: http://msdn.microsoft.com/en-us/library/gg328210.aspx

    So in short, annotation is in a custom file that you need to generate for your organization, or you could reference the sample code helpers.

     

    I typically skip this model and use late bound entities: http://msdn.microsoft.com/en-us/library/gg309272.aspx


    Phil Edry – Altriva Solutions – http://www.altriva.com/AltrivaBlog.aspx
    • Marked as answer by Karl Parsons Monday, August 29, 2011 8:57 PM
    Monday, August 29, 2011 8:32 PM
  • Ah yes, you gotta do this bullish:

    CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration" /out:Xrm\Xrm.cs /url:http://Crm/Contoso/XRMServices/2011/Organization.svc /domain:CONTOSO /username:administrator /password:pass@word1 /namespace:Xrm /serviceContextName:XrmServiceContext

    Just found this article, add the Xrm.cs class and you are good to go!

    Thx dude!
    Monday, August 29, 2011 8:39 PM
  • No prob. Feel free to mark my question as answer, or your own response so that people know this question has been resolved.
    Phil Edry – Altriva Solutions – http://www.altriva.com/AltrivaBlog.aspx
    Monday, August 29, 2011 8:49 PM