• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

XamlWriter.Save method Serialization Error: "Constructor on type 'NinjaTrader.Core.Co

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    XamlWriter.Save method Serialization Error: "Constructor on type 'NinjaTrader.Core.Co

    I am having the same problem with System.Windows.Markup.XamlWriter.Save to serialize various controls. I get Error:
    Constructor on type 'NinjaTrader.Core.CoreEnumConverter' not found.
    Code:
    using System.Xml.Linq;
    
    public static void Serialize() {
        TextBlock tb =new TextBlock();
        Grid container = new Grid();
        container.Childen.Add(tb);
        try {
            //works just fine because it was created by my code
            Print(XamlWriter.Save(container));
    
            //works just fine because it was created from my xaml file
            Print(XamlWriter.Save(containerFromXaml));
    
            //works on many controls created by NinjaTrader. 
            Print(XamlWriter.Save(buttonBuyMkt));
    
            //throws an exception for many UI controls created by the platform
            //Error: "Constructor on type 'NinjaTrader.Core.CoreEnumConverter' not found."
            Print(XamlWriter.Save(existingContainer));
        }
        catch(Exception e) {
            Print(e.Message);
        }
    }
    On suggestion from the original poster that it may be a security/accessibility issue with the temp dlls NinjaTrader creates, I compiled the code, deleted the script files and imported the dll. The rest of the add-on functionality works great except the serialization method call which traps the same error message.

    Please help!

    Thanks

    #2
    Hello xcondor,

    Thank you for the post.

    I wanted to ask, what specifically is the end goal that you are trying to achieve here? is it to save the values of your addon with the workspace or to generate XAML code for later use?

    in the case you are trying to add persistence to your addon to save values, there is an interface to do that. https://ninjatrader.com/support/help..._interface.htm

    Regarding generating xaml dynamically, this wouldn't necessarily be something our support could assist with. If that is the case, I would likely suggest to instead make a string of the xaml syntax you want. For any properties or values that need to be changed dynamically, you could use string replacement patterns to do so.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      I wanted to ask, what specifically is the end goal that you are trying to achieve here? is it to save the values of your addon with the workspace or to generate XAML code for later use?
      The latter. It is for testing during developing addons.

      It is not my markup. It is already on the page. I am just trying to serialize it.

      The XamlWriter is the simplest out of the box xml writing tool. It works like a charm on just about anything. So how come it is getting snagged on this enum?

      It has to do with culture lookup table. But I am using the default/invariant culture
      Last edited by xcondor; 05-09-2018, 02:48 PM.

      Comment


        #4
        Hello xcondor,

        I wouldn't be certain as XamlWriter is not something that is used in NinjaScript or documented for any use in NinjaScript. All xaml in the platform/samples are typed out, or stored in an assembly as compiled xaml.

        XamlWriter can be used in C# in general but likely does not account for the structure of NinjaTraders types and multiple assemblies. Additionally, when generating dynamic xaml or doing serialization, the target object needs to be programmed with that in mind. The error states that the object in question does not have a constructor so it wouldn't be able to be serialized.

        I really couldn't suggest anything here for XamlWriter specifically, likely using a string with substitutions would be my suggestion for types that fail with XamlWriter.

        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NinjaCustomer, Today, 12:29 PM
        0 responses
        1 view
        0 likes
        Last Post NinjaCustomer  
        Started by Steve L, Today, 11:32 AM
        0 responses
        2 views
        0 likes
        Last Post Steve L
        by Steve L
         
        Started by prabbala, Today, 10:41 AM
        0 responses
        1 view
        0 likes
        Last Post prabbala  
        Started by bebbus, Today, 10:36 AM
        0 responses
        3 views
        0 likes
        Last Post bebbus
        by bebbus
         
        Started by edmata1109, Today, 10:18 AM
        0 responses
        8 views
        0 likes
        Last Post edmata1109  
        Working...
        X