Json included in coolite assembly

  1. #1

    Json included in coolite assembly

    Hello everyone, i'm already working with the 0.4.1 release in a project. Some parts of the system are being changed to use coolite controls but some others are not there yet. When integrating we realized that some errors appeared because we have references to Newtonsof.Json and Newtonsoft.Json.Converter ourselves in order to perform some other tasks.

    I'm wondering if it could be possible to distribute Json separately from Coolite assembly so user can actually decide what version to use and probably avoid overlapping. What do you guys think?

  2. #2

    RE: Json included in coolite assembly

    Hi oskarni,

    ya, that was my mistake. With the version 0.4.1 release my intention was to make all the .dll's available individually within the manual installation package. Unfortunately I forgot.

    With the 0.5 release, each of the .dll's will be available separately. As well, it is our intention to release the complete Visual Studio Solution (source-code) for the project. With the Solution file obviously you will be able to rip out and/or replace any references.

    We will be also be moving to the Json.net version 2.0 release, hopefully before the coolite 0.5 release.

    Hope this helps answer your questions.
    Geoffrey McGill
    Founder
  3. #3

    RE: Json included in coolite assembly

    Perfect! Nothing else to say about this matter. Thank you very much !

  4. #4

    RE: Json included in coolite assembly

    Many congratulations on the new release - it looks really good!

    I see that the Newtonsoft json dll is still in the package - what is the best way to use my own version of this dll (strongly named) in harmony with Coolite?
  5. #5

    RE: Json included in coolite assembly

    Just changing the Project Reference to point to your own build of Json.NET should work. We point to a Strong Named version of the Assembly stored within the \Coolite.Ext.Web\Build\Resources\Assemblies\Newton soft.Json\ folder.

    We upgraded to Json.net 2.0, although *I think* everything should still work with the previous 1.x Json.net if that's a requirement.

    Hope this helps answer your question.
    Geoffrey McGill
    Founder
  6. #6

    RE: Json included in coolite assembly

    Hello Geoffrey

    From what I understand your reference to the Newtonsoft.Json folder is hidden - wouldn't it be simpler for users if they could directly reference this library using 'using's?

    If I use coolite and want to reference Json.net at the same time, I get conflicts that I am using the same library twice - if you made your Newtonsoft.Json folder visible to me I could user the Newtonsoft functionality directly without all the hassle that is currently necessary.

    I hope I explained that clearly enough. :)
  7. #7

    RE: Json included in coolite assembly

    @Digbert,

    If you reference Coolite.Toolkit and another (separate) instance of the Newtonsoft assembly within the same project, you will get conflicts. But, you should be able to build directly off the Newtonsoft instance that is included with the Toolkit .dll.

    The following example demonstrates creating a custom Json Serialization Method.

    Example

    <%@ Page Language="C#" %>
    <%@ Import Namespace="Newtonsoft.Json" %>
    <%@ Import Namespace="System.IO" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Ext.IsAjaxRequest)
            {
                var employee = new { Name = "Bill", Age = 25, StartDate = DateTime.Today };
    
                this.Label1.Text = this.MySerializer(employee);
            }
        }
        
        public string MySerializer(object obj)
        {
            StringWriter sw = new StringWriter();
            JsonTextWriter writer = new JsonTextWriter(sw);
    
            writer.QuoteName = false;
    
            JsonSerializer serializer = new JsonSerializer();
            serializer.Converters.Add(new JSONDateTimeJsonConverter());
            
            serializer.Serialize(writer, obj);
    
            return sw.GetStringBuilder().ToString();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <ext:ScriptManager ID="ScriptManager1" runat="server" />
        
        <ext:Label ID="Label1" runat="server" />
    </body>
    </html>
    Another option would be to download the project source and change the Newtsoft assembly reference, then rebuild the .dll.

    Hope this helps.


    Geoffrey McGill
    Founder

Similar Threads

  1. Replies: 10
    Last Post: Aug 01, 2011, 1:58 PM
  2. Could not load file or assembly Coolite.Ext.Web
    By ranganath in forum 1.x Help
    Replies: 0
    Last Post: May 04, 2010, 9:11 AM
  3. Replies: 2
    Last Post: Sep 25, 2008, 4:28 AM
  4. [CLOSED] Coolite.Utilities Assembly ?
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Sep 15, 2008, 1:20 PM

Posting Permissions