Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 577477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:09:27+00:00 2026-05-13T14:09:27+00:00

I selected Class Library option in C# Vis Studio Express to create a DLL

  • 0

I selected Class Library option in C# Vis Studio Express to create a DLL which holds heaps of my commonly-used methods etc…

I’m trying to create a textbox in the class file, so that when I add the dll to another project all i have to type is:

MyControls.Create(TextBox);

…And it will create a text box and return it to me and then i can add it to the form.

I know how to create classes etc, so , my quesiton is… Why can’t I use System.Windows.Forms is a class file? I have the following in my Class1.cs file:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyControls
{
    public class class1
    {
        public object Create(object control)
        {
            System.Windows.Forms.TextBox t = new System.Windows.Forms.TextBox();
            // textbox properties go here etc...

            return control;
        }
    }
}

BUT the red squigly lines keep telling me that “The type of namespace ‘Windows’ does not exist in the namespace ‘System’ (Are you missing an assembly reference)?”

Have I forgotten to add something here…??

Thank you 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:09:27+00:00Added an answer on May 13, 2026 at 2:09 pm

    It sounds as if you are missing a reference to System.Windows.Forms; add that reference and your code should compile fine.


    Side Note
    I do get a bit curious about your method:

    public object Create(object control)
    {
        System.Windows.Forms.TextBox t = new System.Windows.Forms.TextBox();
        // textbox properties go here etc...
    
        return control;
    }
    

    What is the input parameter used for? If you don’t use it there is no need to pass it. Also, since the method is supposed to create controls for you, you could change the return type to Control. That will remove the need to cast it in order to add it to the form. I would suggest design the method like this instead (making use of generics):

    public T Create<T>() where T : Control
    {
        T control  = Activator.CreateInstance<T>();
        // textbox properties go here etc...
    
        return control;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Starting at http://developer.android.com/training/index.html I selected the [ FIRST CLASS > ] button which takes
removeClass doesn't remove the class selected from div.upvote in the js below, but addClass()
I'm adding a style class to an node if it's selected and then remove
I am trying to display only selected items in list view. public class Mact
<ul class="leftbutton" > <li id="menu-selected">Sample 1</li> <li>Sample 2</li> <li>Sample 3</li> <li>Sample 4</li> <li>Sample 5</li>
First i selected images from photo library to ALAsset Library and after that i
I have a post type which is used to upload banners in wordpress. Using
I have a class library project that i have made. Let's call it ClassA.
What is the best way to create library agnostic wrapper for JS library selectors?
I create a form based on a model , like seen below: class ContactSelectionForm(forms.ModelForm):

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.