0

Call in my application

Essentials.Class.LoadProgressIndicater(parent)

Direct method fails

LoadProgressIndicater(object parent)
{
    var temp = parent as XtraForm; //XtraForm third party control/dll
}

Indirect method works

LoadProgressIndicater(object parent)
{
    _LoadProgressIndicater(parent);
}

_LoadProgressIndicater(object parent)
{
    var temp = parent as XtraForm; //XtraForm third party control/dll
}

Why does this happen and is there a cleaner approach?

Error

The type is defined in an assembly that is not referenced. You must add a reference to assembly

hooch
  • 1
  • 4
  • What is the error message you are getting? – Zay Lau Aug 23 '16 at 14:11
  • 2
    As written, there are no reason why it would be different... so I think that crucial information is missing from the question. – Phil1970 Aug 23 '16 at 14:31
  • According question http://stackoverflow.com/questions/20660999/the-type-is-defined-in-an-assembly-that-is-not-referenced-how-to-find-the-cause and http://stackoverflow.com/questions/17246899/the-type-xxx-is-defined-in-an-assembly-that-is-not-referenced , may I know is that 2 methods located in different code files? – Zay Lau Aug 23 '16 at 14:36

1 Answers1

0

Resolved

A constructor with the same number of arguments must be evaluated through implicit conversion as to which function member(constructor) would be better.

Hence why I needed to add the reference to the second project so the compiler could determine which constructor was better.

If the constructors don't have the same number of arguments, evaluation doesn't need to occur, and the compiler doesn't need the reference to the second project.

Solution

Made just one method to handle all instances

public static void LoadProgressIndicator(object parent_control)
{
 if (parent_control is XtraForm)
    LoadProgressIndicator(parent_control as XtraForm, null, null, null);
 else
 {
    if (parent_control is XtraUserControl)
       LoadProgressIndicator(null, parent_control as XtraUserControl, null, null);
    else
    {
       if (parent_control is System.Windows.Forms.Form)
          LoadProgressIndicator(null, null, parent_control as System.Windows.Forms.Form, null);
       else
          LoadProgressIndicator(null, null, null, parent_control as System.Windows.Forms.UserControl);
    }
 }
}
hooch
  • 1
  • 4