Reference to a form in another project

D

David Gagné

Hello,
My C# solution is composed of 2 projects, a class library project and a
Windows application project. The window in one project calls the DLL in the
other. That's ok.

Now, to better test the solution I would like to create a new Windows
application project in that solution so that my 2 other projects are not
impacted by this third project. Now this new project would contain the
startup Form from which I could open my Form in the previous project or call
the DLL directly.

My problem is that I don't know how to show a form from another project of
the solution since it is possible to add a reference to a project only for
DLLs.

Summary:
SolutionA contains
- Project1 (Form1)
- Project2 (DLL)
- Project3 (Form2)

How can I make Form2 opens Form1?

Thanks,
David.
 
N

Nick Malik

Hello David,

A dll project can contain a windows form. There is nothing wrong with that.
It is not trivial to change a Windows EXE project into a dll project. On
the other hand, it is quite easy to simply create a new DLL project and add
an Existing Item to it, and point to the windows form that you created for
your Windows EXE. Once you have all the code from the EXE project, then
simply delete the original project from your solution.

Now, you have two DLLs. When you add your new windows EXE, you can make a
reference to both.

--- Nick
 

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