I’m trying to create a DLL for an existing project. The existing project is an application that calculates interest rates and is a Windows Form.
The code I’ve been given to create the DLL includes references to a TextBox and a MessageBox.
Here’s a sample method in that code:
public static bool IsPresent(TextBox textBox)
{
if (textBox.Text == "")
{
MessageBox.Show(textBox.Tag + " is a required field.", Title);
textBox.Focus();
return false;
}
return true;
}
I’ve never created a class library/dll before, so I followed the instructions here.
When I build the solution (for the class library), I get the error:
Error 1 The type or namespace name ‘TextBox’ could not be found (are you missing a using directive or an assembly reference?) J:\LoanApplication\ValidatorSolution\ValidatorSolution\Class1.cs 24 38 ValidatorSolution
And I get it; I understand what the error is saying. My problem is that I don’t know how to get around it.
Any advice?
You need to reference System.Windows.Forms(use this guide) and include a using statement
For each external type you’re using in your library, you need to help VS determine where it is and which one you mean.