Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to solve different assemblies after recompile

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

    How to solve different assemblies after recompile

    I have an indicator (MyIndicator), which has an internal class (MyClass).
    My problem is that after a recompile, the assembly changes so this simple check is going to be false:

    if (myObject is MyClass)....

    Why?
    Because after recompile, the assembly changes, so AssemblyQualifiedName is different.

    NinjaTrader.Indicator.MyIndicator+MyClass, 95b2eab7f5ce4ef4a45668b8c386bfdd, Version=7.0.1000.31, Culture=neutral, PublicKeyToken=null

    NinjaTrader.Indicator.MyIndicator+MyClass, 20377f1f822648c8ab1daa5abb59e22b, Version=7.0.1000.31, Culture=neutral, PublicKeyToken=null


    maybe someone can point me to the right direction...

    #2
    Hello Zapzap,

    Thank you for the post.

    Are you specifically seeing this condition become false in your tests or do you have a sample demonstrating the is check not comparing a type correctly? If so could you provide the sample along with any setup instructions needed to see the result you are?

    Generally in the platform we would recommend to use the fully qualified name when comparing types such as:

    if(myObject is NinjaTrader.Indicator.MyIndicator.MyClass)



    I look forward to being of further assistance.

    Comment


      #3
      The two outputs were printed by:

      Print(myObject.GetType().AssemblyQualifiedName);
      Print(typeof(MyClass).AssemblyQualifiedName);

      the problem is smaller with comparsion. The worst part is that it is unable to cast it.

      Comment


        #4
        Hello Zapzap,

        Do you have a specific test you can provide where your comparison is failing along with any setup instructions? Unfortunately I have not had any other specific reports of comparisons like this failing, without a specific example I am unsure of a resolution for your question. If you can provide a sample I could look further into a solution.

        As noted previously I could suggest to use the fully qualified name rather than the AssemblyQualifiedName property.

        You can export the sample you are using that demonstrates the problem using the steps here: http://ninjatrader.com/support/helpG...nt7/export.htm

        Please let me know if I may be of additional assistance.

        Comment


          #5
          Okay, this is really a superquick mashup and it trows an internal NT error, so I can't print the assemblies, but it throws the error nonetheless AFTER recompile:
          (can't convert the same class to the same class because they are in different(ly named) assemblies.

          Failed to set property 'MyObject' for indicator 'AssemblyTest': Object of type 'NinjaTrader.Indicator.AssemblyTest+MyClass' cannot be converted to type 'NinjaTrader.Indicator.AssemblyTest+MyClass'.




          PHP Code:
          namespace NinjaTrader.Indicator
          {
              [Description("")]
              public class AssemblyTest : Indicator
              {
                  //a simple class
                  public class MyClass
                  {
                      public string JustAName { get; set; }
                      public MyClass()
                      {
                          JustAName = "joe";
                      }
                  }
          
          
                  //a simple field with a property
                  MyClass myObject = new MyClass();
                  [XmlIgnore]
                  [TypeConverter(typeof(ExpandableObjectConverter))]
                  public MyClass MyObject
                  {
                      get {return myObject; }
                      set{ myObject = value; }
                  }
          
                  //minimal needed stuff
                  protected override void Initialize(){}
                  protected override void OnBarUpdate() {}
              }
          } 
          

          Comment


            #6
            Originally posted by Zapzap View Post
            Okay, this is really a superquick mashup and it trows an internal NT error, so I can't print the assemblies, but it throws the error nonetheless AFTER recompile:
            (can't convert the same class to the same class because they are in different(ly named) assemblies.

            Failed to set property 'MyObject' for indicator 'AssemblyTest': Object of type 'NinjaTrader.Indicator.AssemblyTest+MyClass' cannot be converted to type 'NinjaTrader.Indicator.AssemblyTest+MyClass'.




            PHP Code:
            namespace NinjaTrader.Indicator
            {
                [Description("")]
                public class AssemblyTest : Indicator
                {
                    //a simple class
                    public class MyClass
                    {
                        public string JustAName { get; set; }
                        public MyClass()
                        {
                            JustAName = "joe";
                        }
                    }
            
            
                    //a simple field with a property
                    MyClass myObject = new MyClass();
                    [XmlIgnore]
                    [TypeConverter(typeof(ExpandableObjectConverter))]
                    public MyClass MyObject
                    {
                        get {return myObject; }
                        set{ myObject = value; }
                    }
            
                    //minimal needed stuff
                    protected override void Initialize(){}
                    protected override void OnBarUpdate() {}
                }
            } 
            
            That is an internal framework error message that surprisingly actually has no ill effect and happens only the first time after compilation, but not on any subsequent use. Most of us have learned to live with it.

            Search the forum on the phrase: "cannot be converted to type ", and you will get about 17 threads that discuss the issue in various contexts.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            558 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            545 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X