Share A Class File in C#

A

Adhal

Hello,
I think it is impossible, but is there a way to share a class file between two different
projects that can belong in the same solution (if that is going to help)? I don't want to maintain
two pieces of the same code and I would prefer to avoid creating a common shared library.

Thank you
:)
 
A

Adhal

Thanks Peter,

"add existing file..." just copies the file to your project and does not link it. I agree, it
seems that a shared library is the only way. Shame really.
 
A

Arne Vajhøj

Adhal said:
I think it is impossible, but is there a way to share a class file
between two different projects that can belong in the same solution (if
that is going to help)?

You could use a junction/link.

But I would recommend against it. Concurrency issues, source
control problems, undefined ownership etc..

Lib must be the way to go.

Arne
 
F

Family Tree Mike

Adhal said:
Thanks Peter,

"add existing file..." just copies the file to your project and does
not link it. I agree, it seems that a shared library is the only way.
Shame really.




--
Adhal Freeware
http://www.adhal.org

There are only 10 types of people in the world: Those who understand
binary, and those who don't.


When you choose "Add Existing", the dialog for navigating to the file has an
"Add" button, with a small arrow. That arrow contains the option to "Add as
a link...", which I think is difficult to find.

But like everyone said, build a shared library...
 
H

honguyen

When you choose "Add Existing", the dialog for navigating to the file hasan
"Add" button, with a small arrow.  That arrow contains the option to "Add as
a link...", which I think is difficult to find.

But like everyone said, build a shared library...

In this case, make sure that your class 's code don't include
namespace declaration.
So they 'll use the your project 's default namespace.
 
C

Cor Ligthert[MVP]

That is were namespaces are made for, simple set a reference to that
namespace.

Cor
 
A

Adhal

Duh! Never saw that before. Thanks.

When you choose "Add Existing", the dialog for navigating to the file
has an "Add" button, with a small arrow. That arrow contains the option
to "Add as a link...", which I think is difficult to find.

But like everyone said, build a shared library...
 
A

Adhal

Possible solution but I think a library is the way to go. Easy, might not be as fast but should work
fine.

Thanks
 
A

Adhal

Mark said:
Easier than dragging a file from one source control project into another
and then clicking "Get latest version"...?

LOL :)

No I guess it isn't. It just less prone to error (don't know what error), and I don't really trust
sourcesafe that much.

Thank you
Adhal
 
A

Andrew Witte

Hahah thankx for posting this. I was bin looking for this for
a while now... Its so simple, I guess I just missed it.

The reason I wanted this was to share the same .cs file
between a 32bit and 64bit project, so I could compile both at
the same time. Am I doing this the best way??
I use the shared library system for many other things.
 

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