Groups | Blog | Home
all groups > dotnet general > october 2004 >

dotnet general : Extending Component Class


pantichd
10/22/2004 9:32:59 PM
Hello,

I'm using a Component Class object to represent a database table. This Data
Access Object (DAO) has a connection object and data adapter object in it
along with a bunch of methods that need to be there every time I create a
new DAO to represent a db table.

Instead of having to code that "common" logic for each new class I'd like to
create a base DAO, put the common logic there and inherit from it (instead
of System.ComponentModel.Component) for each new DAO.

My current steps for creating a new DAO are:
1) Create a new Component Class object
2) Drag the database from the Server Explorer onto the design pane. This
creates the connection object to the db.
3) Drag a table from the database in Server Explorer onto the design pane.
This creates the data adapter object for that table.
4) Create all the common methods in the new DAO

Within an application, each DAO will have the exact same connection object
so I'd like to include that in the base DAO.

Thinking along those lines, I created a new DAO (call it BaseDAO) and did
steps 1, 2 & 4 from above. Then I created another DAO (ChildDAO) that
inherits from the BaseDAO. I was hoping that I would then be able to just do
step 3 from above for this new DAO.

When I try to bring up the designer for ChildDAO I get the following error:

The designer could not be shown for this file because none of the classes
within it can be designed. The designer inspected the following classes in
the file:

ChildDAO --- The base class 'LayerDataAccess.BaseDAO' could not be
loaded. Ensure the assembly has been referenced or built if it is part of
the project.

Both the BaseDAO and ChildDAO objects are in the same project. Does anyone
have any ideas what I'm doing wrong?

Thanks in advance for any help.

David.

David Pantich
10/25/2004 7:00:35 AM
Yes, the base class compiled fine. So did the child class.

The error happens when I try to open the Designer on the child class.

Thanks!



*** Sent via Developersdex http://www.developersdex.com ***
Angelos Karantzalis
10/25/2004 4:20:26 PM
Have you actually compiled the BaseDAO before you created the sub-class ?

Angel
O:]

[quoted text, click to view]

ttupper
12/23/2004 5:45:06 PM
When working with a custom component/control in the designer, you need to
build a design version and a reun-time version of the obejct.

Here is a link overviewing the process.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcresed/html/_core_using_custom_controls_in_the_dialog_editor.asp

Hope it helps.

--tpt

[quoted text, click to view]
AddThis Social Bookmark Button