473,394 Members | 1,759 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,394 software developers and data experts.

Assembly binding / codebase redirect from GAC

Hi,

I am trying to prevent an assembly being loaded from GAC and instead want it
loaded from the application's base directory. However, the assembly always
gets loaded from GAC. How to have it loaded from the application directory?

I read about the bindingRedirect trick in the NG, however, specifying
bindingRedirect did not work for me. Also, MSDN library states that
"Application configuration files can have a codebase setting without
redirecting the assembly version".

Here's my app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="BindingTestDLL"
publicKeyToken="8662c4c21e8ecd7e"
culture="neutral" />
<codeBase version="1.0.2096.38102"

href="file:///D:/Develop/Test/FusionTest/FusionTest/BindingTest/bin/Debug/BindingTestDLL.dll" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

--
Best regards,
Ruslan Popov
Sep 27 '05 #1
7 11066
Hi Ruslan,

As far as I know, .NET app will always look for the assembly in the GAC if
it is a strong named assembly. Does the two assemblies have the same
version number? If so, the app will always use the one in GAC. But if the
version number is different, and you're using binding redirection, you can
redirect it to your local folder.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Sep 29 '05 #2
Hi Kevin,

No, strongly named assemblies can be loaded from any directory. According to
MSDN, looking for an assembly in GAC occurs after version resolution (which
includes examination of app.config), but prior to probing. Accoring to the
following post, binding redirect together with codebase can result in loading
an assembly from the specified path:
http://groups.google.co.uk/group/mic...c5747a81e6da1c

However, that did not work in my tests. Taking into account the date of the
posting, that can be just an older version of .NET framework.

So, because GAC is checked always first, there can be no way to load an
assembly present in GAC from any other place. Why I want that is because I
have an app misworking because it apparently loads assemblies with the same
name and version number installed to GAC by another application, which
(assemblies) differ from those located in the app base directory.

--
Best regards,
Ruslan Popov
"Kevin Yu [MSFT]" wrote:
Hi Ruslan,

As far as I know, .NET app will always look for the assembly in the GAC if
it is a strong named assembly. Does the two assemblies have the same
version number? If so, the app will always use the one in GAC. But if the
version number is different, and you're using binding redirection, you can
redirect it to your local folder.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Sep 29 '05 #3
Hi Ruslan,

As far as I know, binding rediretion can only redirect to a strong named
assembly with different signatures. If you're using a strong named
assembly, try to give a different version number, assembly name or sign
with a different key. You can re-add reference to the assembly in your app.
If the signature is different the original assembly in the GAC is ignored.
If signature is the same, the one in the GAC will always be used.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Oct 4 '05 #4
Hi Kevin,

Thanks. Fortunately, the assemblies in question are our proprietary, so I
have sources for them, so I just changed the version number. (Actually, the
good practice would be to change the version number when sources had changed,
but that was out of my control.) Otherwise, I think I would have trouble.
Because trying to resign an assembly which is already signed (not
delay-signed) by another key appears impossible. If I understand right, this
could result in inability of xcopy-deployment of the app. I'd be happy to
know comments on this from sombody in the Fusion team. Can you bring some of
them here, Kevin?

--
Best regards,
Ruslan Popov
"Kevin Yu [MSFT]" wrote:
Hi Ruslan,

As far as I know, binding rediretion can only redirect to a strong named
assembly with different signatures. If you're using a strong named
assembly, try to give a different version number, assembly name or sign
with a different key. You can re-add reference to the assembly in your app.
If the signature is different the original assembly in the GAC is ignored.
If signature is the same, the one in the GAC will always be used.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Oct 4 '05 #5
Hi Ruslan,

Sorry that I don't know anyone in the Fusion team. But as far as I know,
changing the version number to make the assembly signature different from
the original one is enough. We needn't re-sign it.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Oct 6 '05 #6
Hi Kevin,

Sure, that's enough. Re-signing would be only needed if there was no
sources. Thanks for paying attention to this.

--
Best regards,
Ruslan Popov
"Kevin Yu [MSFT]" wrote:
Hi Ruslan,

Sorry that I don't know anyone in the Fusion team. But as far as I know,
changing the version number to make the assembly signature different from
the original one is enough. We needn't re-sign it.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Oct 6 '05 #7
You're welcome.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Oct 6 '05 #8

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

Similar topics

2
by: Terence Shek | last post by:
Is there a way to set the application binding policy so that it always binds to the latest version of an assembly? I'm hoping there is a way to avoid updating the application's binding...
7
by: Ruslan Popov | last post by:
Hi, I am trying to prevent an assembly being loaded from GAC and instead want it loaded from the application's base directory. However, the assembly always gets loaded from GAC. How to have it...
6
by: Steve | last post by:
I'm playing with late binding and trying a very simple test to load an assembly In my "Host" application I have this code: <code> string modulePath =...
4
by: =?Utf-8?B?SmFu?= | last post by:
I have a .NET 2.0 application divided in two assemblies; the exe and a dll. The application generates a plugin-dll which is then loaded in a separate AppDomain (along with a second instance of my...
7
by: Wiebe Tijsma | last post by:
Hi, I'm running a web application application using the Microsoft.Interop.Security.AzRoles version 1.2.0.0 in the GAC. After an upgrade to Vista, I also have a version 2.0.0.0 in the GAC. I...
1
by: Coaster | last post by:
orig ref here http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/ff29cc370678911d/c0db5b7e3da283b9?lnk=st&q=gac+assembly+new+version&rnum=7#c0db5b7e3da283b9...
0
by: =?Utf-8?B?VmFuIGRlbiBEcmllc3NjaGUgV2lsbHk=?= | last post by:
For deployment reasons I would like to merge several of our assemblies into a single assembly. I am able to do this via the ilmerge.exe utility. Is there a way I can make my application work with...
0
by: Andy | last post by:
Thanks Peter, I thought I'd give an update on this problem. My application had 2 assemblies that contained classed for the Data access and business logic layer. It was on one of them that I was...
4
by: lasida | last post by:
Hi, I have developed an application in C#. Now I'm working on a tool which is again written in c# which will give me all the assemblies referenced by my application. In the code i need to get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.