Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

assembly problem with gac and reference

I'm trying to load an assembly via an app.config file in a c# project.  Basically, I originally added a reference to a .dll within my client c# winform program.  I then modified this .dll (change included minor version # in assembly), did a build, and did an uninstall and install of the .dll in the GAC.  I do not want to rebuild the client, but I need to make sure I am referencing the correct version of the .dll.  I have a msgbox that informs me of the version referenced upon program exection.  From reading various web sites, the way to go about doing this is through the app.config file. 

Here is my app.config file...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="filename"
                              publicKeyToken="999999999999"
                              culture="neutral" />
            <codeBase href="file:///C:\dir\filename.dll"/>
                         
                             
        </dependentAssembly>
      </assemblyBinding>
  </runtime>
</configuration>


Here is the run time error message:
"The located assembly's manifest definition with name ____ does not match the assembly reference

The existence of the version attribute of the codebase element does not seem to matter. 

I'm pretty sure the error is just that the .dll registered in the GAC differs from the one referenced in the app.config file.  I can't seem to find a way around this though?  Any one know what I'm missing?

grover
Tuesday, April 26, 2005

also, I do not want to use the <bindingRedirect> method because I want the program to determine the dll to use at run time, again without rebuilding the client each time a new version of the .dll is installed into GAC.

grover
Tuesday, April 26, 2005

"I'm pretty sure the error is just that the .dll registered in the GAC differs from the one referenced in the app.config file.  I can't seem to find a way around this though?  Any one know what I'm missing?"


CORRECTION:  Not the reference in the app.config file, but within the client program itself.

grover
Tuesday, April 26, 2005

Using <bindingRedirect> does not force you to recompile the application.

Jeff Mastry
Tuesday, April 26, 2005

Don't I have to specify the version that i want to use with <BindingRedirect> though?  I am under the impression I do.  I tried using 1.* as the version, but I got the same error.  I need to use a version that will not be known before runtime, thus, I cannot hard code the version # in the <bindingRedirect> attribute.  Thats where I'm running into problems.  I want to pull the version from the GAC, but the version coded in the client differs and throws that error.

I have this feeling there's something wrong with the way I'm thinking on this one.   

grover
Tuesday, April 26, 2005

Yes, you must specify a version for bindingRedirect.

If you can access the assemblie's types via an interface or delegates you could use Assembly.LoadWithPartialName to get an assembly reference to the latest version at runtime. However, with this method, you can't have a direct design-time reference to the assembly (thus the need for interfaces and/or  delegates).

Jeff Mastry
Tuesday, April 26, 2005

*  Recent Topics

*  Fog Creek Home