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

Can't Figure Out This Error

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

    Can't Figure Out This Error

    Hey everyone. I've been working on both indicators and addon projects using VisualStudio 2019. Been working great for months but now I don't know what I've done, but I can't get anything to compile anymore. Error = CS0579 "Duplicate 'global::System.Runtime.Versioning.TargetFramework Attribute' attribute." NinjaScript File = \NETFramework, Version = v4\5AssemblyAttributes.cs

    I'm really at a loss as to what to do here.

    NinjaTrader 8.0.22.2 64-bit, Windows10 pro, OS build 18363.1256, MS Visual Studio 2019 version 16.6.4, Microsoft.NETFramework version 4.8.03752

    Any help would be greatly appreciated

    Brennan

    #2
    Hello,


    Thanks for your post.

    Another client had this issue and resolved it after installing a clean environment. You could do the same and that would resolve the issue, but I would like to see if we can find out how the compiler is finding the duplicate attribute.

    Try this first

    If you search for "System.Runtime.Versioning" or "AssemblyAttributes" in the Documents\NinjaTrader 8\bin\Custom\ folder, does anything turn up? If so, please move that file out of the bin/Custom folder and then test compiling again. If you have some detail on how those files got there, it will be helpful to note for other clients that may hit this issue.

    Try this second

    If this does not turn anything up, I may then suggest performing a Repair operation with a NinjaTrader installer after you have renamed the Documents\NinjaTrader 8\bin folder to something like "binSAVE." This will create a new bin folder that is clean with only system NinjaScripts added.

    We should not see an issue compiling here, however any 3rd party DLL's would be excluded and we will see compile errors there. You could remove the references from the NinjaScript Editor (Right Click > References) or add the DLL's and associated CS files back in for those DLL's to resolve those errors, but I would suggest testing with the references removed first as a sanity check.

    Once you see that everything compiles, you can bring in the CS files (and DLL's) from your binSAVE\Custom\folder and everything will be back in working order.

    Installers can be downloaded here - https://ninjatrader.com/PlatformDirect

    Related thread: https://ninjatrader.com/support/foru...jascript-error

    If you find the file that has the duplicate attribute added, please report back here.

    We look forward to assisting.
    Marco G.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your help Marco. Sure enough, there was a second "System.Runtime.Versioning" file I found there. Removing it resolved the issue.

      As far as how it got there, there's 2 possibilities:
      1. Around the same time I had downloaded Heiken-Ashi-8. There wasn't an installer or anything like that I just opened the zip file and put the .cs file in the Custom folder along with all the other indicators.
      2. Also around that same time, the active user account on this machine had changed for a bit. Before the change NT8 was running and was connected to a realtime data stream from my broker. This was left running when the active user account changed and later when the active user account came back to where NT8 was running, everything kinda freaked out for a minute or two with both the broker and the NT8. (No response, windows opened/closed on their own, a couple of errors to acknowledge) and then everything seemed to go back to normal.

      I'm leaning towards the former because it was messing around in the same folder but I don't really know for sure.

      Anyway, thanks for your help, I'm back up and running again!

      brennan

      Comment


        #4
        Hello Marco,

        Definitely recommend the search for "System.Runtime.Versioning" or "AssemblyAttributes" in the Documents\NinjaTrader 8\bin\Custom\ folder and remove anything other than the 4.5 version. I got the duplicate files from doing a build from Visual Studio, which I had just updated. This approach is much better than the clean install as you don't lose your workspaces, etc.

        Thanks!
        Matt

        Comment


          #5
          I use the "Open project in Visual Studio" link to edit my scripts.

          This is how I got the runtime error message:
          1) I installed latest version of NT8 (8.0.23.2)
          2) When I went to edit one of my indicators, Visual Studio told me to download latest version of .Net Framework as the one I have is older than the one NT has. And so I installed 4.8 (developer pack).

          To resolve the issue, I followed instructions above, then renamed the old one.

          Comment


            #6
            I ran into the same problem.
            In the bin/Custom directory there is an obj directory that has those files in it on in debug and one in release directory. Dropping the obj directory clears the error
            The way I got them there I think is I flipped in Visual Studio the pulldown from Debug into Release. It looks like that Visual studio triggers this obj directory to be created and the NT8 compiler is not ignoring this obj directory.
            You have to remove it, renaming does not solve the problem.

            Wessel

            Comment


              #7
              I just had the same error and these posts were very helpful. Thank you.

              Comment


                #8
                Same error and solution "remove anything other than the 4.5 version" worked for me.
                Thanks a lot, StealthM93 and Marco.
                fx.practic
                NinjaTrader Ecosystem Vendor - fx.practic

                Comment


                  #9
                  Originally posted by Wessel View Post
                  I ran into the same problem.
                  In the bin/Custom directory there is an obj directory that has those files in it on in debug and one in release directory. Dropping the obj directory clears the error
                  The way I got them there I think is I flipped in Visual Studio the pulldown from Debug into Release. It looks like that Visual studio triggers this obj directory to be created and the NT8 compiler is not ignoring this obj directory.
                  You have to remove it, renaming does not solve the problem.

                  Wessel
                  Same experience for me as Wessel - can easily be recreated.

                  Comment


                    #10
                    Originally posted by BrennanSalibrici View Post
                    Hey everyone. I've been working on both indicators and addon projects using VisualStudio 2019. Been working great for months but now I don't know what I've done, but I can't get anything to compile anymore. Error = CS0579 "Duplicate 'global::System.Runtime.Versioning.TargetFramework Attribute' attribute." NinjaScript File = \NETFramework, Version = v4\5AssemblyAttributes.cs

                    I'm really at a loss as to what to do here.

                    NinjaTrader 8.0.22.2 64-bit, Windows10 pro, OS build 18363.1256, MS Visual Studio 2019 version 16.6.4, Microsoft.NETFramework version 4.8.03752

                    Any help would be greatly appreciated

                    Brennan
                    I am having this same issue with version: 8.1.1.3 64-bit. I keep removing the >NETFramework,Version-v4.8.AssemblyAttributes.cs file and it is created during compile.

                    Any Ideas about what is causing the issue?

                    Thanks

                    Comment


                      #11
                      Hi cod0973,

                      Do not build or compile with Visual Studio or save the project/solution with Visual Studio. If you need to add/remove files (like copying a Strategy, for example) use the NinjaScript Editor to do those type of actions. To compile while using VS, just have a NinjaScript Editor window open (no files within the editor need to be open, just the editor itself). Then, when you save in VS, the NinjaScript Editor window will do the compilation for you.

                      Hope that helps!
                      Matt

                      Comment


                        #12
                        You can compile directly in Visual Studio if you make a compiled assembly, but it requires a more tedious setup. It's better to do it as StealthM93 suggests unless your needs require that. As he rightly points out, as soon as you type ^S and save your file, the script editor will begin compiling your changes and will report any issues.
                        Bruce DeVault
                        QuantKey Trading Vendor Services
                        NinjaTrader Ecosystem Vendor - QuantKey

                        Comment


                          #13
                          I removed all my VS 2022 versions of the 4.8 .NET and reinstalled the SDK for 4.8. I have no problem at the moment. I am not sure how the original issue arose unless there was some sort of update. I like to use Visual Studio to profile the memory and CPU for my strategies. I also have the Ninjatrader main project compiled as debug to verify some of my programs.

                          Comment


                            #14
                            When VS 2022 compiles the project for NinjaTrader.Custom.csproj, it creates an "obj" folder. You can remove the folder if it causes problems or just remove one of the duplicate names of .cs files under it depending upon if you are using release or debug. I was unable to debug my strategies unless it was compiled.

                            Comment


                              #15
                              Hello cod0973,

                              Bruce is providing good information. Do not compile with Visual Studio.

                              The forum post below discusses this error.
                              I installed the latest version of NT8. I have all updates of Windows 10 installed. I have also the latest version of Visual Studio. When I compile from the Ninjascript editor it works fine. When I use VS and want to build in VS, I am getting the following error in the NinjaScript Editor: \NETFramework,version=v4\6\1AssemblyAttr
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by MarianApalaghiei, Today, 10:49 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by love2code2trade, Yesterday, 01:45 PM
                              4 responses
                              28 views
                              0 likes
                              Last Post love2code2trade  
                              Started by funk10101, Today, 09:43 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post funk10101  
                              Started by pkefal, 04-11-2024, 07:39 AM
                              11 responses
                              37 views
                              0 likes
                              Last Post jeronymite  
                              Started by bill2023, Yesterday, 08:51 AM
                              8 responses
                              46 views
                              0 likes
                              Last Post bill2023  
                              Working...
                              X