Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Assembly search order (Bin/GAC)

731 views
Skip to first unread message

Stan

unread,
Oct 1, 2003, 10:16:25 AM10/1/03
to
Where does Framework look for an assembly first, in GAC or Bin?

I always thought that GAC is used first, but it looks like it is not..

If a project has a subproject, how would it change the search order?
Here is an example where I got stuck:

MyProject
Bin
Assembly 1.0
MySubproject
Bin
Assembly 1.1

Let's say GAC has Assembly 1.1.

What is happening here is when a page in MySubproject is called it pulls
Assembly 1.0
from MyProject\Bin, ignoring Assembly 1.1 that sits in both MySubproject\Bin
and GAC.

I'm trying to make sense of it...

Thanks,

-Stan


Jacob Yang [MSFT]

unread,
Oct 2, 2003, 5:20:29 AM10/2/03
to
Hi Stan,

The run time uses the following steps to resolve an assembly reference:

1. Determine the correct assembly version by examining applicable
configuration files, including the application, publisher policy, and
machine policy configuration files. In a Microsoft Internet Explorer Web
scenario where the configuration file is located on a remote machine, the
run time must locate and download the application configuration file first.
This step only occurs for strong-named assemblies. Since simple named
assemblies don't undergo version checking, policy files are not checked.

2. Check whether the assembly name has been bound-to before and, if so, use
the previously loaded assembly.

3. Check the global assembly cache. If the assembly is found there, the run
time uses this assembly. This step only occurs for strong-named assemblies.

4. Probe for the assembly using the following steps:

1) If configuration and publisher policy do not affect the original
reference and if the bind request was created using the Assembly.LoadFrom
method, the run time checks for location hints.
2) If a code base is found in the configuration files, the run time checks
only this location. If this probe fails, the run time determines that the
binding request failed and no other probing occurs.
3) Probes for the assembly using the heuristics described in the probing
section below. If the assembly is not found after probing, the run time
requests the Windows Installer to provide the assembly. This acts as an
install-on-demand feature.
4) Finally the directory the caller loaded from is used as the last probing
location.

Note: searching the GAC only occurs for the strong-named assemblies.

In your case, the assembly under the MyProject\Bin will be referenced,
unless you have an applicable configuration files, including the
application, publisher policy, and machine policy configuration files,
which specified the codeBase.

Does it answer your question? If I have misunderstood your concern, please
feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Stan

unread,
Oct 2, 2003, 11:51:03 AM10/2/03
to
> In your case, the assembly under the MyProject\Bin will be referenced,
> unless you have an applicable configuration files, including the
> application, publisher policy, and machine policy configuration files,
> which specified the codeBase.
>
> Does it answer your question? If I have misunderstood your concern, please
> feel free to let me know.
>
Jacob,

If runtime uses assembly currently in memory and ignores GAC how can I make
two assemblies run side-by-side?

Apparently in my case there was an assembly version 1.0 in Bin and memory
but there also was version 2.0 in GAC.

Can I force runtime to ignore version 1.0 loaded in memory and use 2.0 from
GAC?

This question comes up because it is hard to deploy new version of assembly
without restarting IIS - old assembly is loaded in memory and therefore
runtime ignores the new one...


Jacob Yang [MSFT]

unread,
Oct 4, 2003, 3:16:02 AM10/4/03
to
Hi Stan,

To force your app to search the GAC while it wants to resolve a reference
to an assembly, the assembly being referenced must be strongly-named and it
also should be installed into GAC (shared assembly).

Secondly, to force the app to reference to certain version of assembly, you
should use an applicable configuration files, including the application,

publisher policy, and machine policy configuration files, which specified
the codeBase.

Thirdly, to implement side-by-side, the assembly also should be a shared
assembly.

Does it answer your question? If I have misunderstood your concern, please
feel free to let me know.

Best regards,

Stan

unread,
Oct 6, 2003, 8:25:06 AM10/6/03
to
Jacob,

Can you tell me what the search order is in by example?

1) Let's say GAC has strongly-name assembly Comp1 of version 2.0

2) The web app has subproject with the following versions of the same
assembly

MyWeb
Bin Comp 1.0
Subproject
Bin Comp 2.0

3) The user opens a page from Subproject. What version of assembly will be
loaded?

4) If by the time of opening a page from Subproject, the version 1.0 of an
assembly is already loaded into memory, does it change anything?

Thanks,

-Stan


"Jacob Yang [MSFT]" <ji...@online.microsoft.com> wrote in message
news:PCg$hdkiDH...@cpmsftngxa06.phx.gbl...

Jacob Yang [MSFT]

unread,
Oct 8, 2003, 3:07:27 AM10/8/03
to
Hi Stan,

Firstly, I will answer your question in step 3 above. When a web page
located in Subproject was request, which assembly was loaded depends on the
following:

1. Runtime gets the sufficient info on the assembly to the referred from
the metadata,
2. Then, runtime checks whether there is any configuration is available. If
found, it will search the codeBase, checking whether a matched assembly was
found there.
3. Runtime checks the memory only when the step 2 above failed.
4. If no assembly was targeted in memory, and if the assembly to be
resolved is a strong-name assembly, runtimes next tries to search the GAC
with the info on the assembly.
5. If searching GAC also failed, the local BIN folder will be searched.

In your sample, the BIN folder under the MyWeb will be searched, unless the
Subproject was also marked as a virtual directory in IIS.

As for your question 4, there are many chances for us to instruct the
runtime which assembly should be loaded. As I mentioned above, checking
configuration files occurs before checking the memory. That is, we can make
use of any valid configuration file to intervene the runtime probe.

In addition, only the matched assembly in memory may be targeted by runtime.

0 new messages