Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 {
            [COLOR="Green"]//works just fine because it was created by my code[/COLOR]
            Print(XamlWriter.Save(container));
    
            [COLOR="Green"]//works just fine because it was created from my xaml file[/COLOR]
            Print(XamlWriter.Save(containerFromXaml));
    
        [COLOR="Green"]    //works on many controls created by NinjaTrader.[/COLOR] 
            Print(XamlWriter.Save(buttonBuyMkt));
    
            [B][COLOR="Green"]//throws an exception for many UI controls created by the platform[/COLOR]
           [COLOR="Red"] //Error: "Constructor on type 'NinjaTrader.Core.CoreEnumConverter' not found."[/COLOR][/B]
            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 TraderBCL, Today, 04:38 AM
        1 response
        6 views
        0 likes
        Last Post bltdavid  
        Started by martin70, 03-24-2023, 04:58 AM
        14 responses
        105 views
        0 likes
        Last Post martin70  
        Started by Radano, 06-10-2021, 01:40 AM
        19 responses
        606 views
        0 likes
        Last Post Radano
        by Radano
         
        Started by KenneGaray, Today, 03:48 AM
        0 responses
        4 views
        0 likes
        Last Post KenneGaray  
        Started by thanajo, 05-04-2021, 02:11 AM
        4 responses
        471 views
        0 likes
        Last Post tradingnasdaqprueba  
        Working...
        X