Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unable to load custom assembly. Original version...

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

    Unable to load custom assembly. Original version...

    Hi,

    I have a custom external dll (my source code) that I use to provide an interface between NinjaTrader and an external trading application. If I change the assembly info in the dll code or have an interface change, I get the above message on NinjaTrader startup. The message requests I recompile the strategy involved which of course, I can't do because NinjaTrader won't start.

    I can delete NinjaTrader.Custom.dll, recompile all my NinjaTrader custom code (I lose the compilations but not the source), close the project without saving the work spaces (because the indicators and strategies are all deleted from the work spaces) and restart. All then works.

    I have to be doing something majorly wrong because I can't imagine this is the expected way to do things. However, your initial message could certainly use some work - basically we are shutting down until you recompile your offending module but you can only do that while NinjaTrader is running.

    How should I be replacing a custom dll?

    #2
    Hello ScottB,

    Is this an importable file that is being imported with a reference and is overwriting the original each time you make a change?

    Below is a public link to the help guide on this.


    To confirm, you are not manually changing files in the filesystem, correct?

    It should be compiling when you import the newer version...
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Yes, the dll is referenced with a using statement. To update the file, I shut NinjaTrader down, copy over the dll (and a supporting dll) and restart NinjaTrader. This is all custom code build using Visual Studio 2017.

      Comment


        #4
        Originally posted by ScottB View Post
        How should I be replacing a custom dll (when NinjaTrader won't start)?
        Try these steps.

        -- STEP 1: Emergency Delete of DLL Reference --

        Exit NinjaTrader.

        Edit file config.xml (make a backup first).

        Look for section with <References> tag.

        Remove your DLL filename from this section.

        Save file config.xml (keep a backup).

        Delete the actual DLL file from the "bin/Custom" folder.

        Start NinjaTrader.

        -- STEP 2: Rebuild DLL per normal --
        -- STEP 3: Add DLL as Reference per normal --
        Last edited by bltdavid; 06-12-2018, 05:31 PM.

        Comment


          #5
          Originally posted by bltdavid View Post
          Remove your DLL filename from this section.
          Editing your config.xml can certainly screw things up.

          For example, if the DLL file above is a low-level assembly
          that other assemblies require, make sure you also delete
          all higher-level assemblies that depend upon the DLL file
          you are deleting.

          Compile/Debug/Fix any code in Visual Studio as necessary.

          Inside the NinjaTrader editor, add them all back as references,
          then recompile.

          Comment


            #6
            bltdavid,

            Thank you for the advice, I will try that next time it happens. Usually it is a simple matter of copying the dll over but every once in a while, it is a total mess.

            Comment


              #7
              Originally posted by ScottB View Post
              ...it is a total mess.
              That usually happens when you change the arguments (aka signatures) of methods in some kind of subtle but significant way.

              Minor changes inside methods and you are probably fine.
              Adding new methods and you are probably fine.
              etc etc

              But subtle changes to method signatures (esp those that are called often) and such changes can break lots of other calling code in strange and messy ways.

              The C# feature called "Interfaces" is one way to get around this issue.
              Last edited by bltdavid; 06-13-2018, 01:20 AM.

              Comment


                #8
                bltdavid,

                Thanks for the clarification on when this is likely to happen. I do use interfaces for communication from the dll to the NinjaTrader strategy (I am not sure how else you could do it) and of course, I can make direct calls from the NinjaTrader strategy to the dll.

                Now I have a different issue.

                Comment


                  #9
                  I am now getting an exception on start up

                  2018-06-14 23:25:18:907 *************** unhandled exception trapped ***************
                  2018-06-14 23:25:18:907 Input string was not in a correct format.
                  2018-06-14 23:25:18:908 System.FormatException: Input string was not in a correct format.
                  at System.Version.VersionResult.SetFailure(ParseFailu reKind failure, String argument)
                  at System.Version.TryParseComponent(String component, String componentName, VersionResult& result, Int32& parsedComponent)
                  at System.Version.TryParseVersion(String version, VersionResult& result)
                  at System.Version.Parse(String input)
                  at System.Version..ctor(String version)
                  at ActiproSoftware.Text.Languages.DotNet.Reflection.I mplementation.AssemblyName.ParseFullName(String fullName)
                  at ActiproSoftware.Text.Languages.DotNet.Reflection.I mplementation.BinaryAssemblySerializer.#4Dc(Binary Reader #o6b)
                  at ActiproSoftware.Text.Languages.DotNet.Reflection.I mplementation.BinaryAssemblySerializer.LoadFromStr eam(IBinaryAssemblyMetadata metadata, Stream stream)
                  at ActiproSoftware.Text.Languages.DotNet.Reflection.I mplementation.FileBasedAssemblyRepository.GetOrCre ate(Assembly assembly, IAssemblyName assemblyName, String location)
                  at #Grc.#tsc.Add(Assembly #sxc, IAssemblyName #4tc)
                  at #Grc.#tsc.Add(Assembly #sxc)
                  at NinjaTrader.Gui.NinjaScript.Editor.ActiproManager. <>c.<LoadIntelliPromptAssemblies>b__20_0(Object o)
                  at System.Threading.ExecutionContext.RunInternal(Exec utionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
                  at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
                  at System.Threading.QueueUserWorkItemCallback.System. Threading.IThreadPoolWorkItem.ExecuteWorkItem()
                  at System.Threading.ThreadPoolWorkQueue.Dispatch()

                  I am not sure this is something I can fix on my end but if it is possible, any advice is welcome.

                  Comment


                    #10
                    What action are you taking when this error occurs?
                    You mean 'on startup' as in simply starting NinjaTrader?
                    Like, right away, immediately?
                    Before Control Center window is displayed?

                    It looks like this happens inside the NinjaScript editor.
                    (probably a hidden window, in order to run the compiler)

                    I see <LoadIntelliPromptAssemblies> in the stack trace.

                    Perhaps there is something quirky being done around this?
                    Are there any VS features that can affect this?
                    Anything that can be disabled?

                    Hmm, did you target the correct .Net version?

                    Comment


                      #11
                      Hello ScottB,

                      Thank you for your update.

                      Please send us your log and trace files so we may investigate this exception further.

                      You can do this by going to the Control Center-> Help-> Email Support

                      Ensuring 'Log and Trace Files' is checked will include these files. This is checked by default.

                      Please list 'ATTN: Patrick H' in the subject line and reference this thread in the body of the email.

                      I look forward to assisting you further.

                      Comment


                        #12
                        Originally posted by ScottB View Post
                        2018-06-14 23:25:18:907 *************** unhandled exception trapped ***************
                        2018-06-14 23:25:18:907 Input string was not in a correct format.
                        2018-06-14 23:25:18:908 System.FormatException: Input string was not in a correct format.
                        at System.Version.VersionResult.SetFailure(ParseFailu reKind failure, String argument)
                        at System.Version.TryParseComponent(String component, String componentName, VersionResult& result, Int32& parsedComponent)
                        at System.Version.TryParseVersion(String version, VersionResult& result)
                        at System.Version.Parse(String input)
                        at System.Version..ctor(String version)
                        at ActiproSoftware.Text.Languages.DotNet.Reflection.I mplementation.AssemblyName.ParseFullName(String fullName)
                        at ActiproSoftware.Text.Languages.DotNet.Reflection.I mplementation.BinaryAssemblySerializer.#4Dc(Binary Reader #o6b)
                        at ActiproSoftware.Text.Languages.DotNet.Reflection.I mplementation.BinaryAssemblySerializer.LoadFromStr eam(IBinaryAssemblyMetadata metadata, Stream stream)
                        at ActiproSoftware.Text.Languages.DotNet.Reflection.I mplementation.FileBasedAssemblyRepository.GetOrCre ate(Assembly assembly, IAssemblyName assemblyName, String location)
                        at #Grc.#tsc.Add(Assembly #sxc, IAssemblyName #4tc)
                        at #Grc.#tsc.Add(Assembly #sxc)
                        at NinjaTrader.Gui.NinjaScript.Editor.ActiproManager. <>c.<LoadIntelliPromptAssemblies>b__20_0(Object o)
                        at System.Threading.ExecutionContext.RunInternal(Exec utionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
                        at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
                        at System.Threading.QueueUserWorkItemCallback.System. Threading.IThreadPoolWorkItem.ExecuteWorkItem()
                        at System.Threading.ThreadPoolWorkQueue.Dispatch()
                        The input string its complaining about is probably being passed to this,
                        Converts the specified read-only span of characters that represents a version number to an equivalent Version object.


                        It looks like to me some kind of version number somewhere in your assembly is being parsed by System.Version.Parse and it's throwing an exception ...
                        Last edited by bltdavid; 06-15-2018, 10:39 AM.

                        Comment


                          #13
                          bltdavid, you are correct on all counts. After much deleting, rebuilding, re-everythinging, I got by the error and am now back to the original original (2 originals on purpose) issue which appears to be with a 3rd party dll kind of, sort of, maybe.

                          NinjaTrader loads the correct version of a dll (protobuf-net) that is required by a redis support dll (StackExchange.Redis.Extensions.Protobuf) when NinjaTrader starts up (assuming I have my strategy attached to a chart). However, when I enable the strategy which in turn instantiates my dll and my dll starts verifying redis connectivity, etc, StackExchange.Redis.Extensions.Protobuf is eventually called and it appears to do what I think of as a lazy load (does't load its supporting dll's until the first call).

                          At this point, for some reason StackExchange.Redis.Extensions.Protobuf attempts to load the wrong version of protobuf-net dll even though NinjaTrader has already loaded the correct version. The erroneous version just so happens to coincide with the minimum version required as one of its dependencies as per nuget in Visual Studio 2017. I have contacted the developer of StackExchange.Redis.Extensions.Protobuf and he asked that I open a question on nuget so the developers can look into it. I hope this is just a config issue somewhere and if not, I can still downgrade all my dll's to fall into line with the old version their code is attempting to load.

                          If interested, I will add an update once I have some sort of resolution. Sound complicated, it is; I am an algo trader, not a hard core developer. All I really want is for the strategy to be able to communicate via redis/protobuf using the latest dll version. This all falls under the general heading of it seemed like a good idea at the time.
                          Last edited by ScottB; 06-15-2018, 09:32 AM.

                          Comment


                            #14
                            Thanks, I greatly appreciate all the details and lessons you are learning.

                            So, yes, keep the commentary coming!

                            Especially outline any solutions and steps taken that led to a resolution.

                            Any self-discovery "ah-hah" moments are also good ...

                            :-)

                            Comment


                              #15
                              To NinjaTrader support

                              It has been suggested by the support staff for the 3rd party dll that I put the same bindingRedirect directives in NinjaTrader's app.config that I have in my dlls' app.config files. I can open NinjaTrader.Custom.csproj but it doesn't appear to have an app.config file. Is there another way to get at this? The bindingRedirect effectively points any module trying to load the protobuf-net.dll (version 2.3.7.0) to the proper (newer) file (2.3.12.0).

                              Any thoughts/suggestions?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Barry Milan, Today, 10:35 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by WeyldFalcon, 12-10-2020, 06:48 PM
                              14 responses
                              1,428 views
                              0 likes
                              Last Post Handclap0241  
                              Started by DJ888, Yesterday, 06:09 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              40 views
                              0 likes
                              Last Post jeronymite  
                              Started by bill2023, Today, 08:51 AM
                              2 responses
                              16 views
                              0 likes
                              Last Post bill2023  
                              Working...
                              X