How to share a function/form between two projects in a solution

Q

Quy Nguyen

How do I share a function/form in two projects in a
solution?

Solution1
ProjectA
FormX (need in both projects)
ModuleX
ProjectB
FormY (will call FormX in ProjectA)
ModuleY (will call ModuleX in projectA)

Thank you
 
J

Jan Tielens

You need to add a reference from ProjectB to ProjectA. Then you can use
everything that is declared as Public from ProjectA. You can do this by
right clicking on the ProjectB node in the Solution Explorer window, then
choose Add Reference. In the dialog box choose the Projects tab and select
ProjectA.
 
Q

Quy nguyen

I get an error say "An assembly must have a 'dll'
extension in order to be referenced."
 
J

Jan Tielens

Oh, ic: ProjectA is an executable (exe). No problem, in that case, I would
suggest to put the common functionality in a new project e.g. ProjectCommon,
and then add a reference from ProjectA and ProjectB to projectCommon. The
type of ProjectCommon should be Class Library (dll).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top