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 3750994
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:00:40+00:00 2026-05-19T09:00:40+00:00

I am new to C# WinForms. I have made a class (EnhancedForm) which inherits

  • 0

I am new to C# WinForms. I have made a class (EnhancedForm) which inherits Form class. In EnhanceForm I have put some common functions (like validations, common used objects like DataTable and string variables etc, so that I may not have to code same again and again in forms) that I want to use in all forms and next all of my forms inherits this (EnhancedForm).

In DAL (a separate class library) I have a class CommonDB class which have DB related common functions. For database communications I was making an object of CommonDB in all forms. I thought to put CommonDB in EnhancedForm so that I may not have to make its objects in all classes.

Here is something happening that I couldn’t understand. Application runs fine. But if I try to open a form in design view it gives an error. “Object reference not set to an instance of an object. “ I couldn’t view a form in designed mode. If I remove CommonDb object from EnhancedForm and put it in individual forms it works fine and allow to view forms.

If I compile and run this error do not appears. Please guide and help me in this regard.

Thanks

  • 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-19T09:00:41+00:00Added an answer on May 19, 2026 at 9:00 am

    You have code in EnhancedForm that assumes a CommonDb object. At runtime you create that (probably in Form_Loaded) but Design-time it is absent.

    Preferrably, all your code accessing CommonDb should check for null, and/or this.DesignMode

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to WPF and come from a WinForms background and have a fairly
I'm fairly new to database programming in WinForms, and have been using BindingSource, DataSet,
I made a small winforms application to monitor a certain folder for new pdf
Let's suppose I have a Winforms app with a Dictionary that looks like this:
I'm new to winforms and have tried to track down an answer to the
I am new to winforms and I have a datagridview inside a table control.
I have a Winforms application which is working fine.. using a BackgroundWorkerThread to manage
I have a new Winforms application that is replacing an existing Access order processing
Technologies: C#, .Net, Winforms I have a main form that pulls data from a
I have a class that handles events from a WinForms control. Based on what

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.