I have a project ("Project1") that utilizes a number of assemblies ("Assemblies A & B") that are stored in the GAC. However, when I
modify and recompile Assemblies A&B in another instance of VSNET2003 -- and install the new versions in the GAC -- the references in
Project1 are not updated. They still refer to the earlier, unmodified versions of Assemblies A&B.
Needless to say, this makes compiling and running Project1 impossible.
Why aren't the references being updated? Doesn't VSNET2003 check the GAC before compiling a project to see if any of the referenced
assemblies have changed?
- Mark
p.s. BTW, setting Copy Local to True is not an option here, because Project1 also loads Assembly B dynamically, which, because .NET
considers static assembly loads to be distinct from dynamic assembly loads, also breaks the project.
Carlos J. Quintero [VB MVP] - 14 Dec 2005 10:01 GMT
Hi Mark,
The GAC is a deployment mechanism intended to deploy shared assemblies to
end users, and it is not a development mechanism (in other words, you only
take care of the GAC when building the setup of your app). VS.NET uses
references to assemblies located in some folder of the disk, but not in the
GAC. For example, when you reference System.Windows.Forms.dll, you reference
the copy in C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322, not the copy in
the GAC. For that reason, assemblies only in the GAC do not appear in the
Add Reference dialog, see:
How to display an assembly in the Add Reference dialog box
http://support.microsoft.com/default.aspx?scid=kb;en-us;306149
So, in your case you can either use a single solution with 2 projects and
the project references mechanism of VS.NET (CopyLocal=True, etc). or you
need a macro, script or something which copies the assemblies before each
build.

Signature
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio 2005, Visual Studio .NET,
VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
>I have a project ("Project1") that utilizes a number of assemblies
>("Assemblies A & B") that are stored in the GAC. However, when I
[quoted text clipped - 15 lines]
> considers static assembly loads to be distinct from dynamic assembly
> loads, also breaks the project.
Mark Olbert - 14 Dec 2005 15:04 GMT
I'm aware of how you add references to assemblies that are in the GAC.
The issue seems to be a bug in VSNET2003 -- it's not checking for later versions of assemblies when copy local is set to false.
Except when you open a project -- then it does an automatic update of the reference.
- Mark
"Gary Chang[MSFT]" - 14 Dec 2005 12:08 GMT
Hi Mark,
>p.s. BTW, setting Copy Local to True is not an option here,
>because Project1 also loads Assembly B dynamically,
Would you please tell me how do you dynamically load theses strong named
assemblies in your application?
Since the GAC could hold different versions of an assembly, and the
assembly's revision number will be
automatically increased each time it is being built in the VS.NET IDE, so
such behavior would be as expected if
you specify the loading assembly's version number explicitly in your
application.
Thanks!
Best regards,
Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
Mark Olbert - 14 Dec 2005 15:21 GMT
Gary,
I was summarizing a somewhat more complicated picture. I don't actually load the strong named assembly in the GAC statically. What I
do is load an assembly which references a strong named assembly which is already statically referenced in the project. This leads to
a problem with Type resolution. The load is done via LoadFrom(), with a file reference. The assembly I'm loading with LoadFrom() is
the assembly of the project being built.
I do this because I need to be able to resolve Types in the current assembly at design-time. For example, I have a user control
which exposes a property that must be set to a Type exposed by the same assembly that contains the user control. This is similar to
the functionality in VSNET of being able to add user controls defined in an assembly to other controls in the assembly (i.e., the My
Controls toolbox tab).
Example:
Project1 contains a static reference to Assembly A, which is strong-named and in the GAC. This reference, by default, is
Copy Local = false.
Project1 extends a control class (Control C) defined in Assembly A. Call this extended control class Control E.
At design-time, Project1 needs to be able to examine Control E, and potentially allow instances of it to be added to other
controls in the Project. To do this, a control designer in Project1 dynamically loads the Project1 assembly (which, of course, has a
static reference to Assembly A).
If I set Project1's reference to Assembly A to Copy Local = True to get Project1 to automatically update the Assembly A
reference for updates, then the designer insists that typeof(Control E).IsSubclassOf(typeof(Control C)) is False...even though they
are clearly related. For example, typeof(Control E).BaseType.AssemblyQualifiedName is exactly equal to typeof(Control
C).AssemblyQualifiedName.
I've read in the dotnet.framework discussion group that this behavior is by design, because AppDomains maintain two separate lists
of loaded assemblies, one for assemblies that are statically referenced and one for assemblies that are dynamically loaded.
That's why I apparently have to leave Copy Local set to False...even though I'd prefer to have it set to True.
BTW, if you know of another design pattern for examining the assembly of the current project I'd love to hear it. I've always
wondered how VS.NET itself handles the situation.
- Mark
"Gary Chang[MSFT]" - 15 Dec 2005 09:36 GMT
Hi Mark,
>BTW, if you know of another design pattern for examining the assembly
>of the current project I'd love to hear it.
Sorry I am afraid I don't have much experience on such scenario, I can't be
of more help here.
Thanks for your understanding!
Best regards,
Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.