locked
Writing our first CRM PlugIn: Error: Cannot find file? RRS feed

  • Question

  • Hello,

    I am writing my first CRM Plug in and I have received an error that I am trying to get more information on.

    • Entity: Order
    • Event: Post Update
    • Desired process: Fire PlugIn and insert a record into a database table

    The good news is that it appears that my PlugIn ("ErpPlugIn2) is firing.  The bad news is that I can't seem to make heads or tail out of the error message to try to debug.

    Here is the content of ErrorDetails:

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Unexpected exception from plug-in (Execute): ErpPlugIn2.Plugins.PostOrderUpdate: System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.Detail: 
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
      <ErrorCode>-2147220956</ErrorCode>
      <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
      <Message>Unexpected exception from plug-in (Execute): ErpPlugIn2.Plugins.PostOrderUpdate: System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.</Message>
      <Timestamp>2015-04-08T15:58:34.8264424Z</Timestamp>
      <InnerFault i:nil="true" />
      <TraceText>
    
    [ErpPlugIn2.Plugins: ErpPlugIn2.Plugins.PostOrderUpdate]
    [770625b6-90dd-e411-9408-00155d106904: PostOrderUpdate]
    
    Entered ErpPlugIn2.Plugins.PostOrderUpdate.Execute(), Correlation Id: 9ff91cd5-b17f-4452-a875-fa2bd6556c4e, Initiating User: d48e3ef3-0971-e411-93fe-00155d106900
    ErpPlugIn2.Plugins.PostOrderUpdate is firing for Entity: salesorder, Message: Update, Correlation Id: 9ff91cd5-b17f-4452-a875-fa2bd6556c4e, Initiating User: d48e3ef3-0971-e411-93fe-00155d106900
    PostOrderUpdate Starting, Correlation Id: 9ff91cd5-b17f-4452-a875-fa2bd6556c4e, Initiating User: d48e3ef3-0971-e411-93fe-00155d106900
    Microsoft.Xrm.Sdk.OptionSetValue-&gt;Microsoft.Xrm.Sdk.OptionSetValue, Correlation Id: 9ff91cd5-b17f-4452-a875-fa2bd6556c4e, Initiating User: d48e3ef3-0971-e411-93fe-00155d106900
    test order send, Correlation Id: 9ff91cd5-b17f-4452-a875-fa2bd6556c4e, Initiating User: d48e3ef3-0971-e411-93fe-00155d106900
    98765 4/8/2015 11:58:34 AM, Correlation Id: 9ff91cd5-b17f-4452-a875-fa2bd6556c4e, Initiating User: d48e3ef3-0971-e411-93fe-00155d106900
    Exiting ErpPlugIn2.Plugins.PostOrderUpdate.Execute(), Correlation Id: 9ff91cd5-b17f-4452-a875-fa2bd6556c4e, Initiating User: d48e3ef3-0971-e411-93fe-00155d106900
    
    
    </TraceText>
    </OrganizationServiceFault>

    Thanks for your input.

    Wednesday, April 8, 2015 4:10 PM

All replies

  • Hello,

    you plugin is not able to load "System.Net.Http.Formatting, Version=4.0.0.0 assembly, if you are using CRM on premise make sure this file is available under GAC in your CRM server.


    Microsoft Dynamics CRM Training|Our Blog | Follow US | Our Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Wednesday, April 8, 2015 4:58 PM
    Moderator
  • Hello, I Agree with HIMBAP, but there are other solutions too. If you have an external assembly (which is not a common .NET assembly or a CRM assembly), you could:

       
    • Merge the assembly with your plugin Documentation
    • HIMBAP'S Solution
    • Create a webservice with your logic and consume the webservice in your plugin.
    • Download ILMerge and copy the code from the functions from System.Net.Http.Formatting you are using in your plugin. Paste them in your plugin.

    This are some other solutions (HIMBAP, to my opinion, less work :)-)

    Kind Regards

    • Edited by Jochen- Thursday, April 9, 2015 7:02 AM formatting
    Thursday, April 9, 2015 7:01 AM