473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Interesting file managment feature of VS2005

In the process of learning VS2005/C# (having a background in Borland Delphi
2 through 2005) I came across an interesting feature of Visual Studio's file
management. At first, it appeared there wasn't a way for me to 'share'
common business objects (ex. \Projects\Objects\Customer\CustomerObject.cs)
across multiple solutions.
When I select Add -> Existing Item, navigate to the directory, and select
the .CS file and select Add, VS *copies* the file to the solution's
directory (no longer follows the local directory structure or structure
configured in source control).
What happens when, not if, I change the file? Is this a bug? Have I just
become lazy because Delphi's default behavior to adding objects/units is to
*use* the file from where ever you added it from? How can I guarantee that
all our other developers compile the same base source code?

Then a developer on a Borland newsgroup pointed out the Add button in the
'Add Existing Item' dialog box is also a drop-down (yes, very intuitive)
that allows me to 'Add as Link'. Tada, now my business objects are shared,
and not copied.

I brought up my dilemma with 3 Microsoft Visual Studio 'experts' at PDC-2005
who basically told me sharing files in multiple projects wasn't possible
(one actually questioned why anyone would do that).

So my question, why would 'linking' not be the default behavior? Wouldn't
copying lead to more bugs (especially in a multiple developer environment)
and more file management/versioning headaches? Is there a way to make
'linking' the default 'Add' behavior?

Thanks,
Kevin

Nov 28 '05 #1
6 1391
Kevin,

I think that the general idea is that you would want something
side-by-side, which is why they don't just link to the files. It's just the
mindset of the app. Of course, as you have found out, the option is
available to you.

However, you have to remember that if add the same file across your
projects, then those types in that file compiled into each project will not
be the same types in the compiled assembly, and can not be interchanged or
used amongst those assemblies. If this is ok for your project, then that's
fine, but you need to be aware of it.

The thinking behind the questions as to why you would want to do that is
because the typical way to do this would be to have one project where this
file resides, and then reference that assembly from the other projects you
want to use those types in. It is seen as much easier to manage in the face
of changes (which probably leads to the thinking in VS.NET that you would
copy the file to your local project folder).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

P.S. If you asked me, I would have been able to tell you about the "Add as
Link" option =)

"Kevin Frevert" <ke***@workdrinkingdietcoke.com> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
In the process of learning VS2005/C# (having a background in Borland
Delphi 2 through 2005) I came across an interesting feature of Visual
Studio's file management. At first, it appeared there wasn't a way for me
to 'share' common business objects (ex.
\Projects\Objects\Customer\CustomerObject.cs) across multiple solutions.
When I select Add -> Existing Item, navigate to the directory, and select
the .CS file and select Add, VS *copies* the file to the solution's
directory (no longer follows the local directory structure or structure
configured in source control).
What happens when, not if, I change the file? Is this a bug? Have I just
become lazy because Delphi's default behavior to adding objects/units is
to *use* the file from where ever you added it from? How can I guarantee
that all our other developers compile the same base source code?

Then a developer on a Borland newsgroup pointed out the Add button in the
'Add Existing Item' dialog box is also a drop-down (yes, very intuitive)
that allows me to 'Add as Link'. Tada, now my business objects are
shared, and not copied.

I brought up my dilemma with 3 Microsoft Visual Studio 'experts' at
PDC-2005 who basically told me sharing files in multiple projects wasn't
possible (one actually questioned why anyone would do that).

So my question, why would 'linking' not be the default behavior? Wouldn't
copying lead to more bugs (especially in a multiple developer environment)
and more file management/versioning headaches? Is there a way to make
'linking' the default 'Add' behavior?

Thanks,
Kevin

Nov 28 '05 #2
The typical way to share code across projects is to put the shared code
into a DLL and reference that DLL from several projects.

Compiling the same source code into multiple projects, particularly if
they're DLLs, leads to problems, as Nicholas pointed out.

Nov 28 '05 #3
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Og**************@TK2MSFTNGP12.phx.gbl...
Kevin,

I think that the general idea is that you would want something
side-by-side, which is why they don't just link to the files. It's just
the mindset of the app. Of course, as you have found out, the option is
available to you.

Perhaps initially, but in my experience managing thousands of files,
multiple developers (and Dilbert-ish management :), less copying and more
using solves all kinds of problems. Working with Delphi over the years, it
seems VS is taking me ten steps backwards.
However, you have to remember that if add the same file across your
projects, then those types in that file compiled into each project will
not be the same types in the compiled assembly, and can not be
interchanged or used amongst those assemblies. If this is ok for your
project, then that's fine, but you need to be aware of it.
I'm not exactly sure what you are saying. What exactly cannot be
interchanged? If I have a CustomerObject.cs file and a type of Retail,
Dealer, etc, a DLL or EXE would build against one file, not two. If I have
to change a type, all I have to remember is to change one file, re-compile
any/all assemblies/applications that use that file, and I'm done. In VS it
seems the default behavior is copy the file from somewhere (assuming the
developer fetched the correct file from version control) compile and hope
for the best.
The thinking behind the questions as to why you would want to do that
is because the typical way to do this would be to have one project where
this file resides, and then reference that assembly from the other
projects you want to use those types in. It is seen as much easier to
manage in the face of changes (which probably leads to the thinking in
VS.NET that you would copy the file to your local project folder).

Yes, ideally I would want to build an assembly with all the common
libraries/objects and when something changes, I change the assembly and my
apps reflect that change with no changes to app's source code. What scares
me is after using VB4, DLL hell will soon become Assembly hell. As nice as
they were, the VS folks at PDC didn't give me a nice future to look forward
to :)
Hope this helps.


Yes, Thank you.

krf
Nov 28 '05 #4

Kevin Frevert wrote:
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
However, you have to remember that if add the same file across your
projects, then those types in that file compiled into each project will
not be the same types in the compiled assembly, and can not be
interchanged or used amongst those assemblies. If this is ok for your
project, then that's fine, but you need to be aware of it.


I'm not exactly sure what you are saying. What exactly cannot be
interchanged? If I have a CustomerObject.cs file and a type of Retail,
Dealer, etc, a DLL or EXE would build against one file, not two. If I have
to change a type, all I have to remember is to change one file, re-compile
any/all assemblies/applications that use that file, and I'm done.


Yes, but you missed Nicholas's point. The point is that the name of a
type, like Dealer, in .NET is not just "Dealer". It's the name of the
assembly in which it resides, followed by the namespace in which it's
declared, followed by the type name. So, if you compile "Dealer" into
multiple assemblies (DLLs), then the types will be incompatible.

The CLR doesn't care what source file the type came from. All it cares
about is the assembly from which it was loaded, and the namespace and
typename (which in your case would be the same, since it's always
compiled from the same source file). So, if you compile Dealer into a
DLL and compile it into another assembly, the two Dealers will be
incompatible within the CLR.
The thinking behind the questions as to why you would want to do that
is because the typical way to do this would be to have one project where
this file resides, and then reference that assembly from the other
projects you want to use those types in. It is seen as much easier to
manage in the face of changes (which probably leads to the thinking in
VS.NET that you would copy the file to your local project folder).


Yes, ideally I would want to build an assembly with all the common
libraries/objects and when something changes, I change the assembly and my
apps reflect that change with no changes to app's source code. What scares
me is after using VB4, DLL hell will soon become Assembly hell. As nice as
they were, the VS folks at PDC didn't give me a nice future to look forward
to :)


In theory, there should never be an Assembly hell, because there are
only two ways you can deploy DLLs:

1. As private assemblies that live in the same directory as the
executable. So long as every executable has its own directory, you can
release them independently without having DLL version problems.

2. As assemblies installed in the GAC, which supports multiple versions
of the same assembly, and loads the version that the EXE asks for.

I haven't gotten into using the GAC because I work in a small shop with
simple requirements. However, Microsoft has gone to a lot of work to
built a framework that understands versioning and was designed from the
ground up to eliminate DLL Hell. Whether it will make good on that
promise remains to be seen, but it's certainly a huge step forward, and
I think that it removes any objections to using DLLs in the first place.

Nov 28 '05 #5
"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...

Yes, but you missed Nicholas's point. The point is that the name of a
type, like Dealer, in .NET is not just "Dealer". It's the name of the
assembly in which it resides, followed by the namespace in which it's
declared, followed by the type name. So, if you compile "Dealer" into
multiple assemblies (DLLs), then the types will be incompatible.

Yes, I missed the point. So if AssemblyA and AssemblyB are using the same
underlying class (either the same file or copied), you cannot compare/use
types declared in the .CS file in AssemblyC (and AssemblyC has reference to
A & B)? If so, that's a situation I'll try to avoid.

In theory, there should never be an Assembly hell, because there are
only two ways you can deploy DLLs:

1. As private assemblies that live in the same directory as the
executable. So long as every executable has its own directory, you can
release them independently without having DLL version problems.

2. As assemblies installed in the GAC, which supports multiple versions
of the same assembly, and loads the version that the EXE asks for.


IMO, that is pretty close to hell :) I think I'd rather have a bad venereal
disease than managing assemblies/GACs on several hundred PCs (who has what
version installed where?) Too many bad COM dll experiences I guess.

What is the best way to manage common assemblies? How do you decide what is
GAC'ed or what is copied into the application's directory? What keeps a
lazy network admin from copying the assembly in multiple places trying to
solve an end-user problem (one of my bad COM experiences)? Is there a
'best' way?

krf


Nov 28 '05 #6
If you're dealing on that large a scale, I would hunker down with a
book on .NET versioning and figure out how it works. As I said, we
don't use it here, because we're a tiny shop and can control everything
pretty easily, so I'm no expert on how it's designed to work.

The folks in Redmond put a lot of thought into this to solve precisely
the kinds of versioning problems that used to cause DLL Hell. While
their solution may not be ideal, I doubt that it's junk. It's worth
looking into, at the very least.

Nov 29 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: kafooey | last post by:
Hi all, I've been digging around on the newsgroups and the web for a possible answer for this problem, but have so far come up with nothing so thought I would ask here... I have the following...
2
by: Mark Broadbent | last post by:
Anyone know where to do so? I'm finding quite a few annoying bits and it would be nice to have these ironed out before full release! Br, Mark.
9
by: ReidarT | last post by:
How can I zip (compress) a file in vs2005 with windows own zip-program? reidarT
0
by: Mahesha | last post by:
Hi All, I need to know how do we implement a file download feature in ASP.NET. As we see in the MSDN sites (say when we try to download the .NET famework) , refer this URL ...
0
by: shining.sea | last post by:
This might be interesting for web master who have lots of digital and want an easy way to manage them http://digg.com/software/AJAX_Based_File_Managment_Web_Application This company, called...
15
by: Joseph Geretz | last post by:
OK, I'll admit it up front - I just don't get it. Here's our previous VS2003 development model. Developers develop the WS solution on their own workstations, using their own IIS web servers...
0
by: GT | last post by:
This question has been posted before, but without any response so therefore I'm trying once more. I'm trying to embed .resource files into a Windows application in VS2005, and then compile and...
4
by: MarkusR | last post by:
Good day, bare with me while I probably ask a very novice question... I have multiple projects that use the same constants. I want to create a common file they can share. Is this the best way...
1
by: cowboyrocks2009 | last post by:
Hi, I need to develop the functions below for a server in Java. Is there any package or class that I can use ? I just had a look at one namely... com.mindbright.net.ftp. Can you guide me about...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.