Register any version of assembly in ASP .NET page

14,354

Solution 1

Just drop the Version= portion:

<%@ Register Assembly="CrystalDecisions.Web, , Culture=neutral, 
                       PublicKeyToken=692fbea5521e1304"
             Namespace="CrystalDecisions.Web" 
             TagPrefix="CR" %>

However this only works with late binding. If you actually compile any of your assemblies against a specific version of the assembly you will need an assembly binding redirect in your Web.config file.

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="CrystalDecisions.Web"
                  publicKeyToken="692fbea5521e1304"
                  />

        <bindingRedirect oldVersion="10.5.3700.0"
                 newVersion="13.0.2000.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Solution 2

You need to use the assemblyBinding section in your web.config file. See this article.

Solution 3

You could just do this:

<%@ Register Assembly="CrystalDecisions.Web, Culture=neutral,
PublicKeyToken=692fbea5521e1304"
Namespace="CrystalDecisions.Web" TagPrefix="CR" %>

This will allow you load any version.

Share:
14,354
Dileep A
Author by

Dileep A

Updated on June 04, 2022

Comments

  • Dileep A
    Dileep A almost 2 years

    How can I use any available version of an assembly on an ASP .NET page?

    For example, I use this tag before adding a Crystal Reports control on a web page on my computer:

    <%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
    

    However, if I install this web page on a computer that has a different version of Crystal Reports, I would have to change the version part of the assembly attribute:

    <%@ Register Assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
    

    Is there any way I can avoid this by instructing ASP .NET to use the newest available version or specify the minimum required version?

  • Dileep A
    Dileep A about 13 years
    I tried that but got an error: Could not load file or assembly 'CrystalDecisions.Web, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified
  • Paul Alexander
    Paul Alexander about 13 years
    The error is accurate - you're probably missing one of the dependencies of the specific version that was loaded. This is one of the dangers of ignoring the version.
  • Dileep A
    Dileep A about 13 years
    I have three versions of the assembly in my GAC. They all work fine when I specify a version -- I tried with each version. But it fails without the version= portion. According to Process Monitor, w3wp searches for CrystalDecisions.Web.dll and CrystalDecisions.Web.exe only in the /bin folder. It does not seem to look in the GAC. Any way I can fix that?
  • Dileep A
    Dileep A about 13 years
    Your solution seems to have worked for others with the same question. There could be other issues with Crystal Reports installation on my computer.
  • Dileep A
    Dileep A about 13 years
    Thanks. That was my first idea as well, but it resulted in a compilation error.
  • toha
    toha over 3 years
    correct.. I can use this on my page. Hope it will stand forever..