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

Notifications

Announcements

No record found.

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

    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!    

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at

    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

  • Community Member Profile Picture
    on at

    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

  • slx Profile Picture
    386 on at

    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>

     -->

  • slx Profile Picture
    386 on at

    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; }

    }

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans