CodeBase and Dependent Assemblies

  • Thread starter Thread starter Dougie Brown
  • Start date Start date
D

Dougie Brown

Hi

I have a question or two which I'm pretty sure of the answers, but wanted it
confirmed by those who know more than me!!

Basically we want to share assemblies across many applications and allow for
side by side execution, but for reasons that I don’t quite agree with the GAC
is ruled out! These applications are essentially scheduled tasks hence using
the GAC means deploying to many boxes.

So that leaves me with adding a CodeBase element for each dependent
assembly. This works fine except when the referenced assembly also depends
on another assembly in the CodeBase directory, in this case the application
fails with a FileNotFoundException.

Using FusLogVw it's clear that the CodeBase is not used when probing for
this dependent assembly that is not directly referenced by the application.
If I add another dependentAssembly element for this assembly then all is good.

So at last I get to my questions:

When loading an assembly via a CodeBase why doesn't Fusion use the CodeBase
to find any of its dependent assemblies?

Other than the GAC is there an alternative?

Thanks for your help.

Cheers

Doug
 
Hi Doug,

If I understand you completely, you deploy your shared assembly in a shared
URL so that multiple applications use <CodeBase> element to point to this
shared URL. By doing this, you need not deploy the shared assemblies to the
GAC on all the client machines. I think this is why you do not like to use
the GAC solution. If I have misunderstood you, please feel free to tell me,
thanks.

Let's call the first directly referenced shared assembly "AssemblyA" and
call the second indrectly referenced assembly "AssemblyB", can you tell me
under which <dependentAssembly> do you place the <CodeBase> for the
dependent assemblies? If you add the extra <CodeBase> for "AssemblyB" under
the <dependentAssembly> for the "AssemblyA" and it does not work, I think
it is expected. The fusion will first check the <assemblyIdentity> version
matches, will it probe <CodeBase>. That's why we have to add an explict
<dependentAssembly> for that "AssemblyB".

Our original Fusion developer explains <CodeBase> element usage in details
here:
"Codebase hint in config files"
http://blogs.msdn.com/junfeng/archive/2004/11/16/258081.aspx

Another option for your scenario is using AssemblyResolve event. In this
event, you can place your own logic to resolve assembly reference. For
example, you can store the assembly URL in the app.config or registry. The
code in AssemblyResolve event can query to find the assembly for loading.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Jeffrey

Thanks for you answer, the AssemblyResolve event does indeed solve my problem!

Cheers

Doug

"Jeffrey Tan[MSFT]" said:
Hi Doug,

If I understand you completely, you deploy your shared assembly in a shared
URL so that multiple applications use <CodeBase> element to point to this
shared URL. By doing this, you need not deploy the shared assemblies to the
GAC on all the client machines. I think this is why you do not like to use
the GAC solution. If I have misunderstood you, please feel free to tell me,
thanks.

Let's call the first directly referenced shared assembly "AssemblyA" and
call the second indrectly referenced assembly "AssemblyB", can you tell me
under which <dependentAssembly> do you place the <CodeBase> for the
dependent assemblies? If you add the extra <CodeBase> for "AssemblyB" under
the <dependentAssembly> for the "AssemblyA" and it does not work, I think
it is expected. The fusion will first check the <assemblyIdentity> version
matches, will it probe <CodeBase>. That's why we have to add an explict
<dependentAssembly> for that "AssemblyB".

Our original Fusion developer explains <CodeBase> element usage in details
here:
"Codebase hint in config files"
http://blogs.msdn.com/junfeng/archive/2004/11/16/258081.aspx

Another option for your scenario is using AssemblyResolve event. In this
event, you can place your own logic to resolve assembly reference. For
example, you can store the assembly URL in the app.config or registry. The
code in AssemblyResolve event can query to find the assembly for loading.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Doug,

Glad to see my reply can help you. If you need further help, please feel
free to post, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=========================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top