locked
crm 2011 plug-in won't recognize early bound types RRS feed

  • Question

  • Hi,

    crm 2011 plug-in won't recognize early bound types if crmsvcutil generated class is referenced as dll in the plug-in.

    But if i add the class itself it will work.

    I did the Ilmerge as well but it's unable to identify early bound at runtime.

    can somebody help??


    Padmakar - http://gpadmakar.blogpost.com
    Friday, June 10, 2011 6:09 AM

Answers

  • Reference assemblies are not supported in CRM (at least officially) and they can always cause headaches, I strongle discourage them. What you can do is include the generated code from crmsvcutil.exe into each of your plugin assemblies and that should work. You can also include this line of code in your plugin assembly (which is included in the generated code):

     

    [assembly: Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute()]
    


    Gonzalo | gonzaloruizcrm.blogspot.com

    Friday, June 10, 2011 2:39 PM
    Moderator

All replies

  • Hi, I have exactly the same problem, even trying to deploy that common dll in the GAC... :(

    For example, if I try something like this:

    =============================================

    Contact

     

    c = new Contact();

    c.FirstName = "my contact"

    ;

    service.Create(c);

    =============================================

    It doesn't work and an "Unexpected error" is thrown when service.Create(c) is executed

    However, the same with late bound is fine:

    Entity e = new Entity("contact");

    e.Attributes[

    "firstname"] = "my contact";

    service.Create(e);

     


    Microsoft CRM Developer - Solution Designer http://ramontebar.com

    Friday, June 10, 2011 8:07 AM
  • A temporary workaround is to use ToEntity<Entity>():

    Contact c = new Contact

    ();

    c.FirstName =

    "my contact"

    ;

    service.Create(c.ToEntity<

    Entity>() );

    =====================

    But honestly, I don't like it either :(


    Microsoft CRM Developer - Solution Designer http://ramontebar.com
    Friday, June 10, 2011 8:23 AM
  • Reference assemblies are not supported in CRM (at least officially) and they can always cause headaches, I strongle discourage them. What you can do is include the generated code from crmsvcutil.exe into each of your plugin assemblies and that should work. You can also include this line of code in your plugin assembly (which is included in the generated code):

     

    [assembly: Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute()]
    


    Gonzalo | gonzaloruizcrm.blogspot.com

    Friday, June 10, 2011 2:39 PM
    Moderator
  • Great Gonzalo! It works! I placed
    [assembly: Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute()]
    
    in the plugin library and i works fine now.
    Thank you very much!

    Microsoft CRM Developer - Solution Designer http://ramontebar.com
    Friday, June 10, 2011 4:25 PM
  • Great :-)

    Please mark this thread as answered!


    Gonzalo | gonzaloruizcrm.blogspot.com

    Friday, June 10, 2011 6:21 PM
    Moderator