• 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

Windows Notification, DLL dynamic loading

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

    Windows Notification, DLL dynamic loading

    Edit: Windows notification service implemenation is in post #3

    Hi,
    since I'd like raise a windows notification, I'd need to load some additional DLLs but don't want to copy them to the NT folder.
    While not a NT question per se, maybe somebody has experience.

    Basically I'd only need Windows.UI and Windows.Data.Xml.Dom.

    I've experimented with System.Reflection.Assembly but neither Load, LoadFile nor LoadFrom succeeded. Maybe because I'm not loading the correct Windows.UI.dll, I've tried Windows\SysWOW64 and Windows\assembly. Could also be that NT uses a different .NET version.

    Assembly Examples:
    https://stackoverflow.com/questions/...ime-in-c-sharp

    If this is not possible, I've already got a working solution based on a share service writing a message to a file and a powershell raising the notification.
    I'll post whatever solution works best.

    Windows notification code example:
    https://docs.microsoft.com/en-us/pre...2768(v%3Dvs.85)
    Last edited by MojoJojo; 02-29-2020, 08:54 AM.

    #2
    Hello MojoJojo,

    Thanks for your post.

    Dynamically loading DLL's would be outside of the scope of support we can offer.

    I would suggest adding the DLL in the bin/Custom folder, adding a reference, and making sure that works before attempting to load the DLL dynamically. NinjaTrader 8 is built for .NET 4.5 so I would recommend using .NET 4.5 compatible DLLs.

    I'll leave this thread open for any community members that would like to share their input.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hi Jim,

      thanks for your suggestion, unfortunately I found out that the DLLs for raising notifications are native and not assemblies.
      While I am sure there is some way of calling the libraries dynamically, e.g. PowerShell can do it by reading the definitions from winmd files, there isn't much documentation on the web for doing this at runtime. I don't think P/Invoke is sufficient.

      However calling an embedded powershell script works fine, it's not very efficient nor beautiful but does the job, the code is attached.

      Windows notification service setup

      To trigger notifications, the imported share service needs to be configured.
      https://ninjatrader.com/support/help...ng_content.htm
      The application name parameter needs to be correctly set, otherwise the notifications are ignored, Windows PowerShell or NinjaTrader 8 should be fine, if unsure you can pick a reasonable value from the output of a powershell script run in a command line.

      Code:
      powershell -command Get-StartApps
      With live data, the a notification can be raised with

      Code:
      Share("WindowsNotification", String.Format("Indicator alert {0} {1}", new object[]{Instrument.FullName, Bars.GetClose(CurrentBar)}));
      Of course use at your own risk, I'm not liable for anything resulting from the use of the code, not even your profits .

      Version: 1.0.0.3 escapes XML special characters in the script for security reasons, otherwise no change

      Edit: the most efficient method would likely be to write a intermediary dll handling the notification call and invoke it with DLLImport or reflection in NT, depending on if the dll is written in C# or C++
      Attached Files
      Last edited by MojoJojo; 03-02-2020, 02:00 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by WHICKED, Yesterday, 09:03 PM
      1 response
      15 views
      0 likes
      Last Post Emma1
      by Emma1
       
      Started by oleotrim, Yesterday, 11:29 PM
      1 response
      9 views
      0 likes
      Last Post Emma1
      by Emma1
       
      Started by Heavyweight_Prop, Yesterday, 09:06 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_EricB  
      Started by saltminer, Yesterday, 05:49 PM
      0 responses
      10 views
      0 likes
      Last Post saltminer  
      Started by brunoviveiros, Yesterday, 05:32 PM
      0 responses
      6 views
      0 likes
      Last Post brunoviveiros  
      Working...
      X