为什么程序集绑定重定向不工作在我的网站?我的、绑定、重定向、程序

2023-09-04 07:03:34 作者:痞子英雄

我有我从Visual Studio使用内置的开发Web服务器运行一个网站项目。该网站的虚拟路径设置为 /

在web.config中包含的运行时元素

 <运行>
  < assemblyBinding的xmlns =瓮:架构 - 微软COM:asm.v1>
    < dependentAssembly>
      < assemblyIdentity名=CMS.Controls公钥=834b12a258f213f9文化=中性/>
      < bindingRedirect oldVersion =4.1.3518.21577NEWVERSION =4.1.3561.21846/>
    < / dependentAssembly>
  < / assemblyBinding>
< /运行>
 

我已经删除从根配置元素。

下面是错误:

  

无法加载文件或程序集   CMS.Controls,版本= 4.1.3518.21577,   文化=中立,   公钥= 834b12a258f213f9或   它的一个依赖。在位于   集清单定义呢   不匹配的程序集引用。   (从HRESULT异常:0x80131040)

网站迁移造成流量下降的潜在原因

下面是结合的日志:

 操作失败。
绑定结果:HR = 0x80131040。没有可用的描述。
...
日志:显示名称= CMS.Controls,版本= 4.1.3518.21577文化=中性公钥= 834b12a258f213f9
 (完全限定)
...
日志:此绑定从default加载上下文。
日志:正在使用应用程序配置文件:D:\项目\网页\ web.config中
日志:从C使用计算机配置文件:\ WINDOWS \ Microsoft.NET \框架\ V2.0.50727 \ CONFIG \ machine.config中。
日志:后政策参考:CMS.Controls,版本= 4.1.3518.21577文化=中性公钥= 834b12a258f213f9
...
日志:大会名称为:CMS.Controls,版本= 4.1.3561.21846文化=中性公钥= 834b12a258f213f9
警告:比较程序集名称时发生不匹配:版本号
 

在我看来,像它无视我的重定向。我一直在寻找了一个小时,我有一个错字或什么?

解决方案

我知道它已经有一段时间,但也许这可以帮助一个人的某个时候...

我们得到了完全相同的问题上的一些项目, 它是一个web应用,而不是一个网站,但作为该问题的关注引用的程序 我不认为项目类型的区别是有关(我可能是错的)

比方说,我们有以下组件:

WebApplicationAssembly

CMSControlAssembly UserManagementAssembly

WebApplicationAssembly所引用CMSControlAssembly和UserManagementAssembly。

因此​​,我们试图做的CMSControlAssembly的assemblybinding,与和你一样多的成功。

经过一番挖掘的灯亮了起来:

的事情是,我们使用的内部CMSControlAssembly的器WebControls直接在我们的web应用。 (该assemblybinding设置考虑到这一点)

但是CMSControlAssembly通过UserManagementAssembly也参考,这是我们的问题的原因。

UserManagementAssembly用CMSControlAssembly比所使用的web应用所述一个较低版本编译

这次大会较低的版本是无处可通过web应用可以发现,所提供的唯一版本是一个由assemblybinding目标。

因此​​,实际上的错误没有呈现出非功能assemblybinding,但装配失踪UserManagementAssembly。

I have a web site project that I run from Visual Studio using the built in development web server. The virtual path of the web site is set to /

The web.config contains a runtime element with

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="CMS.Controls" publicKeyToken="834b12a258f213f9" culture="neutral" />
      <bindingRedirect oldVersion="4.1.3518.21577" newVersion="4.1.3561.21846" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

I have already removed the xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0" attribute from the root configuration element.

Here is the error:

Could not load file or assembly 'CMS.Controls, Version=4.1.3518.21577, Culture=neutral, PublicKeyToken=834b12a258f213f9' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Here is the log of the binding:

The operation failed.
Bind result: hr = 0x80131040. No description available.
...
LOG: DisplayName = CMS.Controls, Version=4.1.3518.21577, Culture=neutral, PublicKeyToken=834b12a258f213f9
 (Fully-specified)
...
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Project\WebSite\web.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: CMS.Controls, Version=4.1.3518.21577, Culture=neutral, PublicKeyToken=834b12a258f213f9
...
LOG: Assembly Name is: CMS.Controls, Version=4.1.3561.21846, Culture=neutral, PublicKeyToken=834b12a258f213f9
WRN: Comparing the assembly name resulted in the mismatch: Revision Number

Seems to me like it's ignoring my redirect. I've been looking at it for an hour, do I have a typo or something?

解决方案

i know it's been a while, but maybe this can help someone sometime...

We got the exact same problem on some project, it was a webapplication and not a website, but as the problem concern referenced assemblies i don't think the difference of project type is relevant (i may be wrong)

Let's say we have the following assemblies:

WebApplicationAssembly

CMSControlAssembly UserManagementAssembly

WebApplicationAssembly is referencing CMSControlAssembly and UserManagementAssembly.

So we tried to do an assemblybinding on CMSControlAssembly, with as much success as you do.

After some digging the lights came up:

the thing is that we used the webcontrols inside CMSControlAssembly directly within our webapplication. (the assemblybinding was set with this in mind)

But CMSControlAssembly was also referenced by UserManagementAssembly, and this was the cause of our problem.

UserManagementAssembly was compiled with a lower version of CMSControlAssembly than the one used by the webapplication.

This lower version of the assembly was nowhere to be found by the webapplication, as the only version provided was the one targeted by the assemblybinding.

So actually the error is not showing a non functional assemblybinding, but the assembly missing for UserManagementAssembly.