Import a class from another project

  • Thread starter Thread starter ffreino
  • Start date Start date
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.
 
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.
 
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
 
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)
 
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.
 
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.
 
If you are a hobbiest like me and will only use the class in a couple of
projects, then I like "Cut and Paste"!
 
Back
Top