Share A Class File in C#

  • Thread starter Thread starter Adhal
  • Start date Start date
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
:-)
 
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 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
 
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...
 
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.
 
That is were namespaces are made for, simple set a reference to that
namespace.

Cor
 
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...
 
Possible solution but I think a library is the way to go. Easy, might not be as fast but should work
fine.

Thanks
 
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
 
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.
 
Back
Top