473,320 Members | 2,104 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,320 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 11054
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.