Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

The use of additional resource file

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

    The use of additional resource file

    I created an additional resource file to my script MyResource.resx. It contains a string value with the page layout of the XAML. If I try to get the values
    Code:
    string pg = MyResource.pgContent;
    Page page = XamlReader.Parse(pg) as Page;
    or
    Code:
    MyResource.Culture = Thread.CurrentThread.CurrentCulture;
     ResourceManager resourceManager = new ResourceManager("MyResource", Assembly.GetExecutingAssembly());
    string pg = resourceManager.GetString("pgContent", Thread.CurrentThread.CurrentCulture);
    Page page = XamlReader.Parse(pg) as Page;
    or other methods. I get an exception:
    2015-11-04 00:17:01:567|3|16|Error in launch settings window: System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "MyResource.resources" was correctly embedded or linked into assembly "826153671bd64e2394b5775df44be402" at compile time, or that all the satellite assemblies required are loadable and fully signed. at System.Resources.ManifestBasedResourceGroveler.Han dleResourceStreamMissing(String fileName) at System.Resources.ManifestBasedResourceGroveler.Gro velForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResour ceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResour ceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) at System.Resources.ResourceManager.GetString(String name, CultureInfo culture) at NinjaTrader.NinjaScript.Indicators.XXX.OpenSetting s() in e:\Alex\Documents\NinjaTrader 8\bin\Custom\Indicators\XXX.cs:line 4103
    I can not understand where my mistake. Is it possible to use a third-party resource file in the program?
    Last edited by alexr; 11-03-2015, 04:57 PM.

    #2
    I can not understand where my mistake. Is it possible to use a third-party resource file in the program?
    Yes there is

    Comment


      #3
      Hello,

      Thank you for the question.

      I would be happy to look further into this, would you be able to provide a script of what you are currently doing that I can run along with the resource file?

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

      Comment


        #4
        In the archive presented the modified file "SampleAddonWindowTabPage.cs" to demonstrate the concept. Resource File includes a field of type string that contains the content as in the "SampleAddonTabContent.xaml" file.
        I do not want to distribute a script which will be the source code. I think it must be located within the assembly.
        It remains to understand how to make it work.

        re. If I add page content to the resource file of the NT, it works fine.
        Attached Files
        Last edited by alexr; 11-04-2015, 05:49 PM.

        Comment


          #5
          Hello,

          Thank you for providing the sample, that did help answer the question.

          It looks like when using Visual Studio, it automatically generates the ResourceManager basename as the folder + Resource name for the .resx you create. This poses a problem because that will be the incorrect basename or namespace while looking for the resource in NinjaScript.

          To correct this, you would only need to change one item, but you would need to do this every time you update the resource in visual studio because VS will change it back automatically when you save the resource specifically.



          In your MyResource.designer.cs file, look for the line:

          Code:
          new global::System.Resources.ResourceManager("NinjaTrader.Custom.MyResource", typeof(MyResource).Assembly);
          This would need to change to:

          Code:
          new global::System.Resources.ResourceManager("NinjaTrader.Custom.Resource", typeof(MyResource).Assembly);
          The key is "NinjaTrader.Custom.Resource".

          Unfortunately, this would still not be of value. Although it works to use the resource, you currently can not export resources as source or compiled assembly.

          I have submitted a feature request to add the option for resources to also be exported, but currently it would not work.


          Would you instead be able to create a standard class that has a public string property with the xaml rather than a resource? This could be included in an export and would be inside of the compiled assembly.


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

          Comment


            #6
            Hi, Jesse!
            Thank you very much for your answer.
            Considering your council, I changed names in such a way that the name of a resource became identical with a name of the file of a script. But the name of a script differs from an indicator class name. Thus I exported and imported assembly, including the file of resources, without problems.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Aviram Y, Today, 05:29 AM
            0 responses
            2 views
            0 likes
            Last Post Aviram Y  
            Started by quantismo, 04-17-2024, 05:13 PM
            3 responses
            25 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by ScottWalsh, 04-16-2024, 04:29 PM
            7 responses
            34 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by cls71, Today, 04:45 AM
            0 responses
            6 views
            0 likes
            Last Post cls71
            by cls71
             
            Started by mjairg, 07-20-2023, 11:57 PM
            3 responses
            218 views
            1 like
            Last Post PaulMohn  
            Working...
            X