VS2005 Add Reference

M

Mark Olbert

I'm running into some oddball behavior that I hope is not by design.

When I add a reference (via Add Reference) to the bin folder, some, but not all, of the assemblies referenced by the assembly I'm
adding are also added. Example:

Support.dll depends on Splash.dll, DesignTime.dll, License.dll and LicenseDesignTime.dll. Adding a reference to Support.dll brings
in Splash, License and LicenseDesignTime.

I don't want Splash brought in, although I do need License and LicenseDesignTime. If I delete Splash, it gets re-added on the next
compile.

Why is VS2005 adding some but not all of the subsidiary references?

- Mark
 
S

Steven Cheng[MSFT]

Hi Mark,

Welcome to the MSDN newsgroup.

As for the "Add reference" function in VS 2005 ide, are you adding the
reference of a certain assembly by directly pointing to its assembly
file(dll) on the disk rather than reference the assembly's project? If so,
the VS ide will check the assembly's metadata for any dependency and search
the assembly's current directory, if any dependency also exists there, it
will also be copied to ASP.NET web application's private bin dir. For
example, suppose we have the following assemblies:

clslib1.dll , clslib2.dll, clslib1dep.dll

clslib2.dll depend on clslib1.dll, and clslib1.dll depend on clslib1dep.dll.

In our ASP.NET web application, we use the "add reference" to reference
that clslib2.dll assembly, if at that time clslib1.dll and clslib1dep.dll
are also in the same directory, they'll also be copied to the bin dir.
Elsewise, if clslib1.dll or clslib1dep.dll is not found in the same
directory with clslib2.dll, it won't be copied.

In addition, for strong-named assemblies, they're not copied to local bin
dir, the ASP.NET web project will add the reference by adding an entry in
the web.config file(in the compilation/assemblies element), like:

<compilation debug="false">
<assemblies>
...........


BTW, all these above are the VS ide specific behavior. At runtime, .net
framework clr will always probing through its assembly locating rules(from
GAC to local probing path).

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
M

Mark Olbert

Steven,

Yes, I am browsing to the DLL, and not using the Projects tab. Having to include the same project into every website I build so that
I can avoid having all these extraneous references dragged in is not something I want to do.

Well, I see this is yet another change in VS2005 that makes little or no sense to me, and causes me more, not less, work. Sheesh.

- Mark
 
S

Steven Cheng[MSFT]

Thanks for your followup Mark.

Yes, such behavior may not meet all kinds of our requirement, however the
vs 2005 ide's reference control can only ensure that it help add those
existing dependencis it can find. If there is other requirements on
optionally add some dependencies and not all, we may need to do it
manually.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
M

Mark Olbert

But how do you do it manually? Every time I try to add just a single assembly, the silly IDE drags the referenced assemblies along.

Is there some switch I'm not seeing? Or some other option for adding just a specific assembly? All I'm looking at are the options on
the context menu that comes up when you right-click the Bin folder.

- Mark
 
S

Steven Cheng[MSFT]

Hi Mark,

So far I haven't known any buildin swtich or setting which can change this
behavior. VS IDE will always try finding reference's dependency and add
them automatically. BTW, why don't yout to want to copy those dependency?
At runtime, the application will need to load those dependency, if not
existing, there will occur runtime error.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
M

Mark Olbert

Steven,

They just clutter up the bin directory, and the Types defined in them never get called by the website application. In ASPNET1.1 I
would just not include them as references without any problem.

- Mark
 
S

Steven Cheng[MSFT]

Thanks for your followup Mark,

If so, I'm afraid we have to manually remove those items if you do not want
them since VS IDE won't know whether your actual scenario will need to
manually remove those dependency. It always think dependency are necessary
and I think this is the reasonable behavior.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
M

Mark Olbert

Steven,

Unfortunately, you can't remove them...if you do, VS2005 adds them back in on the next compile.

What I don't understand is why this behavior was changed from VS2003. That earlier version didn't add in the dependent references
automatically.

- Mark
 
S

Steven Cheng[MSFT]

Thanks for followup Mark,

I think this change is originally designed to make gathering dependency
assemblies more conveniently, however, seems dosn't meet your concrete
scenario's requirement. BTW, one possible means to automate the removing
assembly task is add another c++ makefile project and add the removing
certain assembly task in it. In the whole solution, make this make file
project's build sequence behind your Application project(which reference
those assemblies).

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
S

Steven Cheng[MSFT]

Hi Mark,

For c# library project, it has pre/post build events itself, for some other
projects like ASP.NET web project, it lack of such events. So we may need
to use such a c++ make file project to simulate the build events. The
following kb article has mentioned this:

http://support.microsoft.com/kb/810230/en-us

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top