Access another project in same solution.

G

Guest

How do you access a form or code from another project in the same solution?
I have a solution that has several projects and I want to be able to load a
form or call code from say Project2 from Project1. I thought it would have
been something as simple as Project2.Whatever, but that does not work.

Thanks
 
C

Carlos J. Quintero [VB MVP]

It depends:

- If you want to access the code from the other project once compiled
(assembly), you need to add a reference, either an assembly reference or a
project reference (the Add Reference dialog has 3 tabs, explore them).

- If you want independent assemblies at run time with no dependencies, only
sharing code at source code level, you can link a file from one project in
another project, using the Add Existing Item dialog, navigating to the file
of the other project, and instead of clicking the Open button, drop down it
and select the Link File option.


--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
J

James Thresher

You will need to add a reference to the other project, you can do this
by going to Projects/Add Reference and select the Projects tab, this
will show all of the projects in your solution. Once you have referenced
the other project you should be able to use its objects.
 
G

Guest

Thanks for the response. I tried adding a reference, but it tells me that an
assembly must have a .dll extension in order to be referenced. I guess I
have to compile the project inot a .dll? How?
 

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