web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

plugin using newtonsoft.json

(0) ShareShare
ReportReport
Posted on by 386

Could you please help with the following issue:

<Message>Unexpected exception from plug-in (Execute): PluginXXXXCreate: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.</Message>

I need to use Newtonsoft.json from Dynamics plugin

I have installed Json.Net using NuGet, these are the settings below. 

packages.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net452" />
</packages>

This is the reference Newtonsoft.json dll added to the Visual Studio project

version 10.0.0.0

XXXXX\Visual Studio Solution\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll

XXX.csprj

<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>

*This post is locked for comments

I have the same question (0)
  • slx Profile Picture
    386 on at
    RE: plugin using newtonsoft.json

    I would like to avoid using newtonsoft.json but I can't get data deserialized

    this is the odata json

    {

     "@odata.context": "http://test_link/$metadata#docs(Id,Code,Version)",

     "value": [

       {

         "@search.score": 1,

         "Id": "3",

         "Code": 3,

         "Version": 1,

         },

    {message2},

    {message3},

    }

    and these my c# classes

     public class OData

       {

           [JsonProperty("odata.metadata")]

           public string Metadata { get; set; }

           public List<Resp> Value { get; set; }

       }

       public class Resp

       {

           public Resp() { }

           public string Id { get; set; }

           public string Code { get; set; }

           public string Version { get; set; }

    }

  • slx Profile Picture
    386 on at
    RE: plugin using newtonsoft.json

    Thank you for reply, is this raising a security issue? (compiling external dll inside plugin sandbox env) ?

    Also , could you please assist with the change of the file ? this is csprj

     <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

     <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

          Other similar extension points exist, see Microsoft.Common.targets.

     <Target Name="BeforeBuild">

     </Target>

     <Target Name="AfterBuild">

     </Target>

     -->

  • Community Member Profile Picture
    on at
    RE: plugin using newtonsoft.json

    if it is just to serialize a json to a data contract, you could use

    Complaint jsonData = new Complaint();
    byte[] result = Encoding.UTF8.GetBytes(data);
                        using (var jsonReader = JsonReaderWriterFactory.CreateJsonReader(result, XmlDictionaryReaderQuotas.Max))
                        {
                            var outputSerialiser = new DataContractJsonSerializer(jsonData.GetType());
                            jsonData = outputSerialiser.ReadObject(jsonReader) as Complaint;
                        }


    -- It saves you from ILMerging Newtonsoft.json.

    you have to add

    using System.Runtime.Serialization.Json;

    Regards,

    Jithesh

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at
    RE: plugin using newtonsoft.json

    You need to use ILMerge to include external dll or another project assembly to your plugin

    Please refer

    gonzaloruizcrm.blogspot.co.uk/.../including-reference-assemblies-in.html

  • slx Profile Picture
    386 on at
    RE: plugin using newtonsoft.json

    and these are installed packages

    PM> Get-Package

    Id                             Version              Description/Release Notes                                                

    --                             -------              -------------------------                                                

    Microsoft.CSharp               4.3.0                Provides support for compilation and code generation, including dynamic...

    Newtonsoft.Json                10.0.2               Json.NET is a popular high-performance JSON framework for .NET            

    NuGetPowerTools                0.29                 Powershell goodies that make working with nuget even easier!    

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans