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

  • Thread starter Thread starter Quy Nguyen
  • Start date Start date
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
 
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.
 
I get an error say "An assembly must have a 'dll'
extension in order to be referenced."
 
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).
 
Back
Top