locked
Callout TypeLoadException: Could not load type... RRS feed

  • Question

  • Hi,

     

    My PostCreate callout is throwing this exception:

     

    Error: ISV code threw exception: assembly: MYCO.CRM.Callout.dll; class: MYCO.CRM.Callout.Events.MyEntityName; entity: new_myentityname, event: postcreate, exception: System.TypeLoadException: Could not load type MYCO.CRM.Common.CrmSdk.new_myentityname from assembly MYCO.CRM.Common, Version=1.0.2763.29368, Culture=neutral, PublicKeyToken=null.

     

    Within MyEntityName.cs, I have:

     

    public override void PostCreate(CalloutUserContext userContext, CalloutEntityContext entityContext, string postImageEntityXml)

    {

    new_myentityname objPCamp = null;

    objMyEntityName = new new_myentityname(); //this line is throwing the exception

    }

     

    I'm using Visual Studio 2003 and compiling for .NET 1.1.

     

    Do I need to declare the new_myentityname object anywhere first?

     

    Thanks.

    Wednesday, July 16, 2008 8:02 AM

Answers

  • HI,

     

    You don't need to register it in other places. If you have both dll on the same directory the runtime should find the Common assembly and be able to load the class. Make sure that you have the last versions of both assemblies in the \server\bin\assembly

     

    Are you using signed assemblies? If that´s the case make sure that both assemblies are signed?

     

    Anyway, you can try another method as temporary solution. Try to use ILMerger to combine both assemblies in one and see if that works. ILMerge http://research.microsoft.com/~mbarnett/ILMerge.aspx

     

    Hope it helps,

    Marco

    Thursday, July 17, 2008 7:21 AM
    Moderator

All replies

  • Hi,

     

    This exception is raised when the runtime is not able of loading the type defined. It seems that you have the class new_myentityname defined in a different assembly than the callout code, MYCO.CRM.Common. In that case you need to copy that assembly to the same directory where you are deploying the callout assembly or register it in the server's GAC (Global Assembly Cache). Have you done one of these?

     

    Hope it helps,

    Marco

    DynamicsCrmKicks

     

    Wednesday, July 16, 2008 10:28 AM
    Moderator
  • Hi Marco,

     

    Thanks for your reply. My directory structure is like this:

     

    - MYCO.CRM.Callout

    - Events

    - MyEntityName.cs

    - callout.config.xml

    - MYCO.CRM.Common

    - Web References

    - CrmSdk

    - MetadataSdk

     

    new_entityname is already listed in CrmSdk. I've also defined it in callout.config.xml.

     

    I have compiled both MYCO.CRM.Callout and MYCO.CRM.Common and placed MYCO.CRM.Callout.dll and MYCO.CRM.Common.dll in the C:\Program Files\Microsoft CRM\Server\bin\assembly folder.

     

    I have updated the CrmSdk web reference. I haven't touched any other files.

     

    Other than that, where else should I register it?

     

    Thanks.

    Thursday, July 17, 2008 2:34 AM
  • HI,

     

    You don't need to register it in other places. If you have both dll on the same directory the runtime should find the Common assembly and be able to load the class. Make sure that you have the last versions of both assemblies in the \server\bin\assembly

     

    Are you using signed assemblies? If that´s the case make sure that both assemblies are signed?

     

    Anyway, you can try another method as temporary solution. Try to use ILMerger to combine both assemblies in one and see if that works. ILMerge http://research.microsoft.com/~mbarnett/ILMerge.aspx

     

    Hope it helps,

    Marco

    Thursday, July 17, 2008 7:21 AM
    Moderator
  • I found out the error I made.

     

    Initially I didn't comple Common.dll, which contained the updated CrmSdk web reference. Then after I compiled it I forgot to do iisreset.

     

    It now works perfectly. Thanks Marco for your help!

     

    Thursday, July 17, 2008 8:44 AM