views:

86

answers:

1

*Just below is my winform client inst with one parameter constructor within the class.*

    private void button1_Click(object sender, EventArgs e)
    {

        string s1 = textBox1.Text;
        int x1 =  Convert.ToInt32(s1);
        int X= x1;        
       ExternalTest ob =  new ExternalTest(X);                 
       string s2 = Convert.ToString(ob.Y);              
        ob.Y = 0;
       textBox2.Text = s2;

And below this is my class that i added to the project The code below is an added class within the assembly. If i tried to make it a class library and and add addreference - it will not build.

class ExternalTest       
{      
            private int _x;
       //     protected new int x
       //     {
       //        get { return _x; }
       //        set  {_x = value ;}
       //     }
             private int y;
             public  int Y 
            {                 
              get {return y =  Mult(_x); }
              set { }
            }        
                internal   int Mult(int _x)
              {                       
              y = _x + 51;   
               return  y;         
               }    

            public ExternalTest(int X)
           {
               _x =  X;             

           }            

      }
}
+1  A: 

Your class is not public by default. You must add public to the definition of the class when you're using it in an external library, or the WinForms client will not be able to see it.

EG:

public class ExternalObj
{
    // ... 
}

Based on the fact that you are getting a compile error only when this class is in an external library, and the numerous times I've forgotten to add public when I've needed it myself, I'm thinking this is probably the issue.

John Rudy