Import a class from another project

F

ffreino

Hi,
I have a Solution with two different Projects.
In one project, can I import a class from another project?


It's something like:

Solution mySolution
ProjectA
Class A1
ProjectB
Class B1

How can I create a ClassB1 object in ClassA1? Is it possible?


Thanks.
 
Z

zacks

Hi,
I have a Solution with two different Projects.
In one project, can I import a class from another project?

It's something like:

Solution mySolution
ProjectA
Class A1
ProjectB
Class B1

How can I create a ClassB1 object in ClassA1? Is it possible?

Thanks.

If ProjectB is a Class Library, just include it's output as a
reference to ProjectA.
 
P

Phillip Taylor

Hi,
I have a Solution with two different Projects.
In one project, can I import a class from another project?

It's something like:

Solution mySolution
ProjectA
Class A1
ProjectB
Class B1

How can I create a ClassB1 object in ClassA1? Is it possible?

Thanks.

Yes, go "Add References" from the project menu (while first project is
selected) and choose the "Projects" tab. Make sure you class is
declared

Public Class A1

Then you can do ProjectB.A1 = new .... etc etc
 
F

ffreino

Yes, go "Add References" from the project menu (while first project is
selected) and choose the "Projects" tab. Make sure you class is
declared

Public Class A1

Then you can do ProjectB.A1 = new .... etc etc

Thanks a lot.
It works... but there is a problem because one project is a
DeviceApplication and the other one is a WindowsApplication so I get
an error message when I try "Add References" Class I trying to import
is a basic class (only a bunch of properties)
 
Z

zacks

Thanks a lot.
It works... but there is a problem because one project is a
DeviceApplication and the other one is a WindowsApplication so I get
an error message when I try "Add References" Class I trying to import
is a basic class (only a bunch of properties)

If you have one or more classes that need to be shared by multiple
projects, you MUST put those classes in a ClassLibrary project and add
that project's output as a reference to any other project that needs
to reference any of the classes in it.
 
F

ffreino

Ok thanks.
I have to try it.

If you have one or more classes that need to be shared by multiple
projects, you MUST put those classes in a ClassLibrary project and add
that project's output as a reference to any other project that needs
to reference any of the classes in it.
 
G

Guest

If you are a hobbiest like me and will only use the class in a couple of
projects, then I like "Cut and Paste"!
 

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