开发者

Register any version of assembly in ASP .NET page

开发者 https://www.devze.com 2023-02-16 02:43 出处:网络
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:

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:

&开发者_如何学编程lt;%@ 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?


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>


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


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.


You need to make sure you download the correct CR version. Since you are using VS 2010, you need to refer to CRforVS_redist_install_64bit_13_0_1.zip (for 64 bit machine) or CRforVS_redist_install_32bit_13_0_1.zip (for 32 bit machine). These two are the redistributable packages. You can download full package as well: CRforVS_13_0_1.exe

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号