How to design a large .NET Project - Reuse Components

  • Thread starter Thread starter aaapaul
  • Start date Start date
A

aaapaul

We are planning a greater .NET Application-System (WindowsForms) with
Visual Studio 2005.

One of my problem is, how to design the objects, that they can be
reused.

E.g. I have a form (with derived textboxes) that should be used in
several Projects.

I tried to copy the form to the other project - with no success.
Adding as a linked component didn´t work, too.

Do I have to work with UserControls and dlls? How about updates.

Who has experience in such things.

Thanks for help
aaapaul
 
I tried to copy the form to the other project - with no success.
Adding as a linked component didn´t work, too.

Either of those approaches *should* work, linking is probably better since
you only have to modify/update the form once.

Is it the main form in each app? If so you should delete the 'Form1' that
VS automatically adds and set your form as the startup form.
 
Thanks Jeff, but I don´t understand your answer.

Let me give you more details.

In VB6 ist was possible to use the same form in several projects:

sample
c:\vb6\p1\
c:\vb6\p2\
c:\vb6\common

I had a frmUni in c:\vb6\common and I could use it in p1 and p2 - I
simple added it to the projects.

Isnt´t this possible in .NET any more?

Outer solutions?

Thanks
 
We are planning a greater .NET Application-System (WindowsForms) with
Visual Studio 2005.

One of my problem is, how to design the objects, that they can be
reused.

E.g. I have a form (with derived textboxes) that should be used in
several Projects.

I tried to copy the form to the other project - with no success.
Adding as a linked component didn´t work, too.

Do I have to work with UserControls and dlls? How about updates.

Who has experience in such things.

Thanks for help
aaapaul


Are the forms to be reused in projects within the same solution, or are they
in different solutions?
If the projects are in a common solution copying is simple and
semi-automatic (select the <formname>.vb to copy and the support files are
automatically copied as well), and adding a link to another project is also
straight forward (right-click on project in solution explorer->Add
reference...).
If you have separate solutions that's a different matter.
 
Thanks.

The problem appears only when I am using a derived control on the box.

I have a solution with
project 1
and
project 2

In project1 there is a form1 that I want to use in project2

So I added in project2 a reference to form1 from project1.

This works.

But when I place a derived textbox (ltext1) on form1.

The error "project1.ltext1 is not defined" appears.

Any idea?

Thanks.
 
If you're serious about it, then I'd recommend
http://www.amazon.com/Developing-Application-Frameworks-NET-Chen/dp/product-description/1590592883

He gives you a good understanding of what you're actually doing and provides
some code.
Most is germane to 1.1, but the concepts apply to whatever version/language
you use.


Read the reviews on the amazon site.





We are planning a greater .NET Application-System (WindowsForms) with
Visual Studio 2005.

One of my problem is, how to design the objects, that they can be
reused.

E.g. I have a form (with derived textboxes) that should be used in
several Projects.

I tried to copy the form to the other project - with no success.
Adding as a linked component didn´t work, too.

Do I have to work with UserControls and dlls? How about updates.

Who has experience in such things.

Thanks for help
aaapaul
 
aaapaul said:
Thanks.

The problem appears only when I am using a derived control on the box.

I have a solution with
project 1
and
project 2

In project1 there is a form1 that I want to use in project2

So I added in project2 a reference to form1 from project1.

This works.

But when I place a derived textbox (ltext1) on form1.

The error "project1.ltext1 is not defined" appears.

Any idea?

Thanks.

Where, exactly, is your subclass of TextBox? In project1, perhaps?
What happens if you add a reference to your subclass to project 2?
 
The Subclass of the Textbox is in Project1 as a reference of Project3
(ltext.vb).

I added the Reference (ltext.vb) to Project2 too, with no success.

Error in Project2: Project1.LText is not defined.

Thanks.
 
See, if you are using the same form in two different projects this may work
- take project2
- add a reference to project1
- add a class in project2 that inherits from project1.form1

this will make the reuse of the entire code you have in project1.form1
possible

regards
Sujith
 
Thanks Sujith!

I did it like you described it.

I have now project1 and project2 in one solution.
I added in project2 a reference to application1 and I said

Dim x As New Project1.Form1()
x.ShowDialog()

This works.

But now I have 2 exe and cant start one exe without the other.

I only wanted to complie the form1 of Project1 in Project 2.

Its seems, thats this behavior is not so good like in VB6
 
In reading some of your other posts it sounds like what you are trying to
do is reference the actual source files from multiple projects directly
within the other projects. The better method is to create multiple class
library projects (.dlls) and reference the dlls in the other projects. Any
classes (and a form is just a class) that needs to be used by your other
projects needs to be made public.

--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com


We are planning a greater .NET Application-System (WindowsForms) with
Visual Studio 2005.

One of my problem is, how to design the objects, that they can be
reused.

E.g. I have a form (with derived textboxes) that should be used in
several Projects.

I tried to copy the form to the other project - with no success.
Adding as a linked component didn´t work, too.

Do I have to work with UserControls and dlls? How about updates.

Who has experience in such things.

Thanks for help
aaapaul
 
Okay,

I guess, you don't want to reuse the form1 in its compiled form. You just
want to add an existing form in "project1" to "project2". Is that so?
(Sorry, if i am wrong).
Adding an existing form in one project to another is possible as follows
Take solution explorer.
Select project, right mouse button, Select Add existing item, browse the
filesystem and select the form1 (which is residing at the project folder of
"Project1").
This when compiled creates only one executable, project2.exe.

Let me know whether this was the solution you were lookin for.

Regards
Sujith
 
"Project1.Ltext"!!!
that means LText when copied to Project2, lost its previous identity
"Project1.Ltext" and it gains the new one Project2.Ltext. I guess you are
working with Visual Basic. Is that so? Then modify the namespace so that
LText retains the same identity in both the projects.

Regards
Sujith
 
Thanks Sujith !

I think this is the solution.

Changing the namespace is not good, because the namespace ist in the
other project wrong than.

But if I delete a part of the namespace.

project1.ltext -> simple ltext.

It works´in both projects.

Programming could be so simple ....

Thanks all
aaapaul
 
Back
Top