By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,053 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,053 IT Pros & Developers. It's quick & easy.

How to share a .cs

P: n/a
ad
I have write a clss, say DM.cs, and I save it in a independent directory
like c:\MyUtil

I have a new project in c:\proj1.

When I use VS to add the existed c:\MyUtil\DM.cs to the new project, the VS
will copy DM.cs form c:\MyUtil
to c:\proj1.

How can I left the DM.cs in the independent directory ?
Nov 16 '05 #1
Share this Question
Share on Google+
16 Replies


P: n/a
make a class library containing only DM.cs.
Then, from your application, and any other app that needs to use it,
add a reference to it.

HTH,
F.O.R.

Nov 16 '05 #2

P: n/a
When you add the code file to the project make sure that you specify it as a
"link file". So in the "Add Existing Item" dialog, after you select the
DM.cs file, select the drop down arrow on the "Open" button and then select
"Link File". The file will now appear in the Solution Explorer, under the
appropriate project, with a code file icon that looks like it has a little
shortcut image over top of it.

--
Tim Wilson
..Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...
I have write a clss, say DM.cs, and I save it in a independent directory
like c:\MyUtil

I have a new project in c:\proj1.

When I use VS to add the existed c:\MyUtil\DM.cs to the new project, the VS will copy DM.cs form c:\MyUtil
to c:\proj1.

How can I left the DM.cs in the independent directory ?

Nov 16 '05 #3

P: n/a
SP
"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...
I have write a clss, say DM.cs, and I save it in a independent directory
like c:\MyUtil

I have a new project in c:\proj1.

When I use VS to add the existed c:\MyUtil\DM.cs to the new project, the
VS
will copy DM.cs form c:\MyUtil
to c:\proj1.

How can I left the DM.cs in the independent directory ?


Add / Existing Item - navigate to DM.cs. Do not click on the Open button but
use the dropdown and choose Link.

SP
Nov 16 '05 #4

P: n/a
ad
But when I click the drop down arrow on the "Open" button, there is no "link
file" appear.
If I right click the DM.cs, there a link item I can select, but the file is
alwayse copy to the c:\Proj1

Can I modified the RelPath = "DM.cs" in the .csproj file?
How to modify it?
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇
:uE**************@TK2MSFTNGP10.phx.gbl...
When you add the code file to the project make sure that you specify it as a "link file". So in the "Add Existing Item" dialog, after you select the
DM.cs file, select the drop down arrow on the "Open" button and then select "Link File". The file will now appear in the Solution Explorer, under the
appropriate project, with a code file icon that looks like it has a little
shortcut image over top of it.

--
Tim Wilson
.Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...
I have write a clss, say DM.cs, and I save it in a independent directory
like c:\MyUtil

I have a new project in c:\proj1.

When I use VS to add the existed c:\MyUtil\DM.cs to the new project, the

VS
will copy DM.cs form c:\MyUtil
to c:\proj1.

How can I left the DM.cs in the independent directory ?


Nov 16 '05 #5

P: n/a
After you select the appropriate cs file in the list, when you click on the
drop down arrow on the "Open" button you should see a small context menu
appear with the options "Open", "Open With...", and "Link File". If you
don't see the "Link File" option, here are a few questions.

Are you creating a web application, by chance? I have read that this option
is not available through web projects due to it being viewed as a security
issue.

If you are not creating a web app, are you using VS.Net 2002 or 2003? It's
possible, although I can't confirm this because I no longer have 2002
installed, that this feature is not in the 2002 product.

--
Tim Wilson
..Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ux**************@TK2MSFTNGP15.phx.gbl...
But when I click the drop down arrow on the "Open" button, there is no "link file" appear.
If I right click the DM.cs, there a link item I can select, but the file is alwayse copy to the c:\Proj1

Can I modified the RelPath = "DM.cs" in the .csproj file?
How to modify it?
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇
:uE**************@TK2MSFTNGP10.phx.gbl...
When you add the code file to the project make sure that you specify it as
a
"link file". So in the "Add Existing Item" dialog, after you select the
DM.cs file, select the drop down arrow on the "Open" button and then

select
"Link File". The file will now appear in the Solution Explorer, under

the appropriate project, with a code file icon that looks like it has a little shortcut image over top of it.

--
Tim Wilson
.Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...
I have write a clss, say DM.cs, and I save it in a independent directory like c:\MyUtil

I have a new project in c:\proj1.

When I use VS to add the existed c:\MyUtil\DM.cs to the new project,
the VS
will copy DM.cs form c:\MyUtil
to c:\proj1.

How can I left the DM.cs in the independent directory ?



Nov 16 '05 #6

P: n/a
SB
It's not on the normal File->Open dropdown menu. You must go to File->Add
Existing Item (or hit CTRL-Shift-A) in VS.Net 2003. You can also get there
by highlighting the project or solution in the Solution Explorer and
right-clicking...it will be under the "Add" submenu. Once you get the "Add
Existing Item" window open, you should clearly see a dropdown arrow that's
on the Open button which has a menuitem titled "Link File" (VS.Net 2003)

If you're using C# Express, the context menu appears to be the only way to
get to this.

HTH,
-sb

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ux**************@TK2MSFTNGP15.phx.gbl...
But when I click the drop down arrow on the "Open" button, there is no
"link
file" appear.
If I right click the DM.cs, there a link item I can select, but the file
is
alwayse copy to the c:\Proj1

Can I modified the RelPath = "DM.cs" in the .csproj file?
How to modify it?
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇
:uE**************@TK2MSFTNGP10.phx.gbl...
When you add the code file to the project make sure that you specify it
as

a
"link file". So in the "Add Existing Item" dialog, after you select the
DM.cs file, select the drop down arrow on the "Open" button and then

select
"Link File". The file will now appear in the Solution Explorer, under the
appropriate project, with a code file icon that looks like it has a
little
shortcut image over top of it.

--
Tim Wilson
.Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...
> I have write a clss, say DM.cs, and I save it in a independent
> directory
> like c:\MyUtil
>
> I have a new project in c:\proj1.
>
> When I use VS to add the existed c:\MyUtil\DM.cs to the new project,
> the

VS
> will copy DM.cs form c:\MyUtil
> to c:\proj1.
>
> How can I left the DM.cs in the independent directory ?
>
>



Nov 16 '05 #7

P: n/a
ad
Thank a lot!
My project is a web application, so I can't find the "link file" item.
But if I open a windows applicaiton, the "link file" appear.
The " link file" can't be used in web application is so inconvenient.

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇
:O8**************@TK2MSFTNGP09.phx.gbl...
After you select the appropriate cs file in the list, when you click on the drop down arrow on the "Open" button you should see a small context menu
appear with the options "Open", "Open With...", and "Link File". If you
don't see the "Link File" option, here are a few questions.

Are you creating a web application, by chance? I have read that this option is not available through web projects due to it being viewed as a security
issue.

If you are not creating a web app, are you using VS.Net 2002 or 2003? It's
possible, although I can't confirm this because I no longer have 2002
installed, that this feature is not in the 2002 product.

--
Tim Wilson
.Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ux**************@TK2MSFTNGP15.phx.gbl...
But when I click the drop down arrow on the "Open" button, there is no "link
file" appear.
If I right click the DM.cs, there a link item I can select, but the file

is
alwayse copy to the c:\Proj1

Can I modified the RelPath = "DM.cs" in the .csproj file?
How to modify it?
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇
:uE**************@TK2MSFTNGP10.phx.gbl...
When you add the code file to the project make sure that you specify it as
a
"link file". So in the "Add Existing Item" dialog, after you select
the DM.cs file, select the drop down arrow on the "Open" button and then

select
"Link File". The file will now appear in the Solution Explorer, under

the appropriate project, with a code file icon that looks like it has a little shortcut image over top of it.

--
Tim Wilson
.Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...
> I have write a clss, say DM.cs, and I save it in a independent directory > like c:\MyUtil
>
> I have a new project in c:\proj1.
>
> When I use VS to add the existed c:\MyUtil\DM.cs to the new project, the VS
> will copy DM.cs form c:\MyUtil
> to c:\proj1.
>
> How can I left the DM.cs in the independent directory ?
>
>



Nov 16 '05 #8

P: n/a
> The " link file" can't be used in web application is so inconvenient.
Agreed. I don't know exactly why this feature was left out of web projects,
other than what I stated before, but it's definitely a nice feature to have.
Your other option in this case is to just compile the shared functionality
into an assembly, class library, and reference this assembly in all projects
as needed.

--
Tim Wilson
..Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ua**************@TK2MSFTNGP09.phx.gbl...
Thank a lot!
My project is a web application, so I can't find the "link file" item.
But if I open a windows applicaiton, the "link file" appear.
The " link file" can't be used in web application is so inconvenient.

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇
:O8**************@TK2MSFTNGP09.phx.gbl...
After you select the appropriate cs file in the list, when you click on

the
drop down arrow on the "Open" button you should see a small context menu
appear with the options "Open", "Open With...", and "Link File". If you
don't see the "Link File" option, here are a few questions.

Are you creating a web application, by chance? I have read that this

option
is not available through web projects due to it being viewed as a security
issue.

If you are not creating a web app, are you using VS.Net 2002 or 2003? It's possible, although I can't confirm this because I no longer have 2002
installed, that this feature is not in the 2002 product.

--
Tim Wilson
.Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ux**************@TK2MSFTNGP15.phx.gbl...
But when I click the drop down arrow on the "Open" button, there is no

"link
file" appear.
If I right click the DM.cs, there a link item I can select, but the file
is
alwayse copy to the c:\Proj1

Can I modified the RelPath = "DM.cs" in the .csproj file?
How to modify it?
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM>
级糶秎ン穝籇 :uE**************@TK2MSFTNGP10.phx.gbl...
> When you add the code file to the project make sure that you specify

it
as
a
> "link file". So in the "Add Existing Item" dialog, after you select

the > DM.cs file, select the drop down arrow on the "Open" button and then
select
> "Link File". The file will now appear in the Solution Explorer,

under the
> appropriate project, with a code file icon that looks like it has a

little
> shortcut image over top of it.
>
> --
> Tim Wilson
> .Net Compact Framework MVP
>
> "ad" <ad@wfes.tcc.edu.tw> wrote in message
> news:ez**************@TK2MSFTNGP10.phx.gbl...
> > I have write a clss, say DM.cs, and I save it in a independent

directory
> > like c:\MyUtil
> >
> > I have a new project in c:\proj1.
> >
> > When I use VS to add the existed c:\MyUtil\DM.cs to the new
project, the
> VS
> > will copy DM.cs form c:\MyUtil
> > to c:\proj1.
> >
> > How can I left the DM.cs in the independent directory ?
> >
> >
>
>



Nov 16 '05 #9

P: n/a
May I ask a question... just for my own education? I'm a WinForms
developer, so I haven't done any ASP work yet.

Why would you want to do this: share a .cs file between multiple dlls /
exes? Isn't the "correct" solution to build the functionality into a
dll and reference the dll from two projects?

Obviously, there's a scenario that calls for "Link File", or the
developers wouldn't have put it in Visual Studio. I just don't know
what it could be. Can someone enlighten me?

Nov 16 '05 #10

P: n/a
One answer that I can give on this, from a compact framework perspective, is
that you can share code between desktop projects and device projects easily
with this option and conditional compilation constants. Technically you can
build a class library against the compact framework and it will be
retargeted against the desktop framework on demand, but if you're attempting
to build a single source file that understands different targets than this
option can be useful. But I guess it's all up to the dev to decide. Possibly
MS put this in there just to allow end devs to decide for themselves how
they want to share functionality - assembly-wise, or source-wise.

--
Tim Wilson
..Net Compact Framework MVP

"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
May I ask a question... just for my own education? I'm a WinForms
developer, so I haven't done any ASP work yet.

Why would you want to do this: share a .cs file between multiple dlls /
exes? Isn't the "correct" solution to build the functionality into a
dll and reference the dll from two projects?

Obviously, there's a scenario that calls for "Link File", or the
developers wouldn't have put it in Visual Studio. I just don't know
what it could be. Can someone enlighten me?

Nov 16 '05 #11

P: n/a
Bruce Wood <br*******@canada.com> wrote:
May I ask a question... just for my own education? I'm a WinForms
developer, so I haven't done any ASP work yet.

Why would you want to do this: share a .cs file between multiple dlls /
exes? Isn't the "correct" solution to build the functionality into a
dll and reference the dll from two projects?

Obviously, there's a scenario that calls for "Link File", or the
developers wouldn't have put it in Visual Studio. I just don't know
what it could be. Can someone enlighten me?


Sure - it's someone wanting to use a single .cs file and being too lazy
to put it in a library. I personally don't think it's something
Microsoft should pander to, but there we go...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #12

P: n/a
ad
Thank again.
I think I must take your option.

I have a single file, say MD.cs. How can I complie it to assembly or class
library?

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇
:#Y**************@TK2MSFTNGP09.phx.gbl...
The " link file" can't be used in web application is so inconvenient. Agreed. I don't know exactly why this feature was left out of web

projects, other than what I stated before, but it's definitely a nice feature to have. Your other option in this case is to just compile the shared functionality
into an assembly, class library, and reference this assembly in all projects as needed.

--
Tim Wilson
.Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ua**************@TK2MSFTNGP09.phx.gbl...
Thank a lot!
My project is a web application, so I can't find the "link file" item.
But if I open a windows applicaiton, the "link file" appear.
The " link file" can't be used in web application is so inconvenient.

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇
:O8**************@TK2MSFTNGP09.phx.gbl...
After you select the appropriate cs file in the list, when you click on
the
drop down arrow on the "Open" button you should see a small context
menu appear with the options "Open", "Open With...", and "Link File". If you don't see the "Link File" option, here are a few questions.

Are you creating a web application, by chance? I have read that this

option
is not available through web projects due to it being viewed as a security issue.

If you are not creating a web app, are you using VS.Net 2002 or 2003? It's possible, although I can't confirm this because I no longer have 2002
installed, that this feature is not in the 2002 product.

--
Tim Wilson
.Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ux**************@TK2MSFTNGP15.phx.gbl...
> But when I click the drop down arrow on the "Open" button, there is no "link
> file" appear.
> If I right click the DM.cs, there a link item I can select, but the file is
> alwayse copy to the c:\Proj1
>
> Can I modified the RelPath = "DM.cs" in the .csproj file?
> How to modify it?
>
>
> "Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇 > :uE**************@TK2MSFTNGP10.phx.gbl...
> > When you add the code file to the project make sure that you specify it
as
> a
> > "link file". So in the "Add Existing Item" dialog, after you
select
the
> > DM.cs file, select the drop down arrow on the "Open" button and

then > select
> > "Link File". The file will now appear in the Solution Explorer,

under the
> > appropriate project, with a code file icon that looks like it has a little
> > shortcut image over top of it.
> >
> > --
> > Tim Wilson
> > .Net Compact Framework MVP
> >
> > "ad" <ad@wfes.tcc.edu.tw> wrote in message
> > news:ez**************@TK2MSFTNGP10.phx.gbl...
> > > I have write a clss, say DM.cs, and I save it in a independent
directory
> > > like c:\MyUtil
> > >
> > > I have a new project in c:\proj1.
> > >
> > > When I use VS to add the existed c:\MyUtil\DM.cs to the new project, the
> > VS
> > > will copy DM.cs form c:\MyUtil
> > > to c:\proj1.
> > >
> > > How can I left the DM.cs in the independent directory ?
> > >
> > >
> >
> >
>
>



Nov 16 '05 #13

P: n/a
Create new C# "Class Library" project, remove the "Class1.cs" file, add your
cs file, set the output location/name through the project properties, set
any assembly specific information (company, description, version) through
the "AssemblyInfo.cs" file, and then compile.

--
Tim Wilson
..Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ul**************@TK2MSFTNGP14.phx.gbl...
Thank again.
I think I must take your option.

I have a single file, say MD.cs. How can I complie it to assembly or class
library?

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇
:#Y**************@TK2MSFTNGP09.phx.gbl...
The " link file" can't be used in web application is so inconvenient. Agreed. I don't know exactly why this feature was left out of web

projects,
other than what I stated before, but it's definitely a nice feature to

have.
Your other option in this case is to just compile the shared functionality
into an assembly, class library, and reference this assembly in all

projects
as needed.

--
Tim Wilson
.Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ua**************@TK2MSFTNGP09.phx.gbl...
Thank a lot!
My project is a web application, so I can't find the "link file" item.
But if I open a windows applicaiton, the "link file" appear.
The " link file" can't be used in web application is so inconvenient.

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇 :O8**************@TK2MSFTNGP09.phx.gbl...
> After you select the appropriate cs file in the list, when you click on the
> drop down arrow on the "Open" button you should see a small context menu > appear with the options "Open", "Open With...", and "Link File". If you > don't see the "Link File" option, here are a few questions.
>
> Are you creating a web application, by chance? I have read that this
option
> is not available through web projects due to it being viewed as a

security
> issue.
>
> If you are not creating a web app, are you using VS.Net 2002 or 2003? It's
> possible, although I can't confirm this because I no longer have
2002 > installed, that this feature is not in the 2002 product.
>
> --
> Tim Wilson
> .Net Compact Framework MVP
>
> "ad" <ad@wfes.tcc.edu.tw> wrote in message
> news:ux**************@TK2MSFTNGP15.phx.gbl...
> > But when I click the drop down arrow on the "Open" button, there
is no > "link
> > file" appear.
> > If I right click the DM.cs, there a link item I can select, but
the file
> is
> > alwayse copy to the c:\Proj1
> >
> > Can I modified the RelPath = "DM.cs" in the .csproj file?
> > How to modify it?
> >
> >
> > "Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇
> > :uE**************@TK2MSFTNGP10.phx.gbl...
> > > When you add the code file to the project make sure that you

specify it
> as
> > a
> > > "link file". So in the "Add Existing Item" dialog, after you select the
> > > DM.cs file, select the drop down arrow on the "Open" button and then > > select
> > > "Link File". The file will now appear in the Solution Explorer,

under
> the
> > > appropriate project, with a code file icon that looks like it
has a > little
> > > shortcut image over top of it.
> > >
> > > --
> > > Tim Wilson
> > > .Net Compact Framework MVP
> > >
> > > "ad" <ad@wfes.tcc.edu.tw> wrote in message
> > > news:ez**************@TK2MSFTNGP10.phx.gbl...
> > > > I have write a clss, say DM.cs, and I save it in a independent
> directory
> > > > like c:\MyUtil
> > > >
> > > > I have a new project in c:\proj1.
> > > >
> > > > When I use VS to add the existed c:\MyUtil\DM.cs to the new

project,
> the
> > > VS
> > > > will copy DM.cs form c:\MyUtil
> > > > to c:\proj1.
> > > >
> > > > How can I left the DM.cs in the independent directory ?
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 16 '05 #14

P: n/a
Well, Tim gave an example of a valid use: a .cs file that contains
conditional compilation instructions, that must be compiled differently
for two different environments. Putting it in a DLL once will, of
course, not have the desired effect. A little scary from my point of
view, but then I don't program for CF yet.

Nov 16 '05 #15

P: n/a
ad
Thank alot!

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇
:uM**************@TK2MSFTNGP15.phx.gbl...
Create new C# "Class Library" project, remove the "Class1.cs" file, add your cs file, set the output location/name through the project properties, set
any assembly specific information (company, description, version) through
the "AssemblyInfo.cs" file, and then compile.

--
Tim Wilson
.Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ul**************@TK2MSFTNGP14.phx.gbl...
Thank again.
I think I must take your option.

I have a single file, say MD.cs. How can I complie it to assembly or class
library?

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇
:#Y**************@TK2MSFTNGP09.phx.gbl...
> The " link file" can't be used in web application is so inconvenient. Agreed. I don't know exactly why this feature was left out of web

projects,
other than what I stated before, but it's definitely a nice feature to

have.
Your other option in this case is to just compile the shared functionality into an assembly, class library, and reference this assembly in all

projects
as needed.

--
Tim Wilson
.Net Compact Framework MVP

"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ua**************@TK2MSFTNGP09.phx.gbl...
> Thank a lot!
> My project is a web application, so I can't find the "link file" item. > But if I open a windows applicaiton, the "link file" appear.
> The " link file" can't be used in web application is so inconvenient. >
>
>
> "Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> 级糶秎ン穝籇 > :O8**************@TK2MSFTNGP09.phx.gbl...
> > After you select the appropriate cs file in the list, when you click on
> the
> > drop down arrow on the "Open" button you should see a small
context
menu
> > appear with the options "Open", "Open With...", and "Link File".
If you
> > don't see the "Link File" option, here are a few questions.
> >
> > Are you creating a web application, by chance? I have read that
this > option
> > is not available through web projects due to it being viewed as a
security
> > issue.
> >
> > If you are not creating a web app, are you using VS.Net 2002 or

2003? It's
> > possible, although I can't confirm this because I no longer have 2002 > > installed, that this feature is not in the 2002 product.
> >
> > --
> > Tim Wilson
> > .Net Compact Framework MVP
> >
> > "ad" <ad@wfes.tcc.edu.tw> wrote in message
> > news:ux**************@TK2MSFTNGP15.phx.gbl...
> > > But when I click the drop down arrow on the "Open" button, there is
no
> > "link
> > > file" appear.
> > > If I right click the DM.cs, there a link item I can select, but

the file
> > is
> > > alwayse copy to the c:\Proj1
> > >
> > > Can I modified the RelPath = "DM.cs" in the .csproj file?
> > > How to modify it?
> > >
> > >
> > > "Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM>
级糶秎ン穝籇
> > > :uE**************@TK2MSFTNGP10.phx.gbl...
> > > > When you add the code file to the project make sure that you

specify
> it
> > as
> > > a
> > > > "link file". So in the "Add Existing Item" dialog, after you

select
> the
> > > > DM.cs file, select the drop down arrow on the "Open" button and then
> > > select
> > > > "Link File". The file will now appear in the Solution

Explorer, under
> > the
> > > > appropriate project, with a code file icon that looks like it

has
a
> > little
> > > > shortcut image over top of it.
> > > >
> > > > --
> > > > Tim Wilson
> > > > .Net Compact Framework MVP
> > > >
> > > > "ad" <ad@wfes.tcc.edu.tw> wrote in message
> > > > news:ez**************@TK2MSFTNGP10.phx.gbl...
> > > > > I have write a clss, say DM.cs, and I save it in a independent > > directory
> > > > > like c:\MyUtil
> > > > >
> > > > > I have a new project in c:\proj1.
> > > > >
> > > > > When I use VS to add the existed c:\MyUtil\DM.cs to the new
project,
> > the
> > > > VS
> > > > > will copy DM.cs form c:\MyUtil
> > > > > to c:\proj1.
> > > > >
> > > > > How can I left the DM.cs in the independent directory ?
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 16 '05 #16

P: n/a
Bruce Wood <br*******@canada.com> wrote:
Well, Tim gave an example of a valid use: a .cs file that contains
conditional compilation instructions, that must be compiled differently
for two different environments. Putting it in a DLL once will, of
course, not have the desired effect. A little scary from my point of
view, but then I don't program for CF yet.


Putting it in a DLL *will* have the desired effect - you just need to
build the DLL twice, once for each environment. Personally I think
that's a nicer solution than sharing a source file between two
different projects.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.