臭名昭着的程序集绑定错误

时间:2010-09-19 12:13:14

标签: visual-studio-2010 64-bit

我真的需要帮助,因为我没有希望纠正这个问题。

我正在使用Office Communications Server 64位库。我在项目中使用了3个dll,Microsoft.Rtc.Collaboration.dll,Microsoft.Rtc.Internal.Media.dll和SIPEPS.dll。我不确定Microsoft.Rtc.Collaboration,但Internal.Media和SIPEPS都是x64。在GAC程序集列表中,Rtc.Collaboration显示处理器Arhitecture下的MSIL,其他显示AMD64。

我的项目使用这些引用编译时没有错误,但在运行时我收到错误:

无法加载文件或程序集“Microsoft.Rtc.Internal.Media”或其依赖项之一。尝试加载格式不正确的程序。

我尝试使用CPU设置为任何CPU来编译项目,但没有任何变化。在x64和x86设置下,我收到此错误。

感谢任何帮助。

更新:下面是装配绑定日志。

=== Pre-bind state information ===
LOG: User = CONTOSO\elodie
LOG: DisplayName = Microsoft.Rtc.Internal.Media
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Microsoft.Rtc.Internal.Media | Domain ID: 9
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/elodie/Documents/Visual Studio 2010/Projects/TFS/proto/Main/Source/WebBot.Web/
LOG: Initial PrivatePath = C:\Users\elodie\Documents\Visual Studio 2010\Projects\TFS\proto\Main\Source\WebBot.Web\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\elodie\Documents\Visual Studio 2010\Projects\TFS\proto\Main\Source\WebBot.Web\web.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/e3d82f59/764fa8c3/Microsoft.Rtc.Internal.Media.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/e3d82f59/764fa8c3/Microsoft.Rtc.Internal.Media/Microsoft.Rtc.Internal.Media.DLL.
LOG: Attempting download of new URL file:///C:/Users/elodie/Documents/Visual Studio 2010/Projects/TFS/proto/Main/Source/WebBot.Web/bin/Microsoft.Rtc.Internal.Media.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

10 个答案:

答案 0 :(得分:61)

我在ASP.NET IIS中遇到了这个问题,在尝试了所有内容之后,我为我的应用池启用了32位并重新启动了应用程序池。然后它奏效了。

在IIS7管理器中: 应用程序池 - > DefaultAppPool - >高级设置 - >将“启用32位应用程序”设置为true。

还要确保选择了正确的.Net版本。

我还将ISAPI 64位设置为“ISAPI和CGI限制”允许,但我不确定这是否有帮助。

答案 1 :(得分:52)

在我的情况下,我遇到了这个问题,因为我正在使用IISExpress运行为x64编译的Web项目。我通过检查Visual Studio中的以下设置来修复此问题:

工具|选项|项目和解决方案|网站项目|使用64位版本的IIS Express

希望这可以帮助其他人处理同样的情况和问题

答案 2 :(得分:18)

用32位版本替换所有三个dll的64位版本,清理Temporary ASP.NET files文件夹并重新编译。现在没有问题。谢谢你的帮助。

答案 3 :(得分:4)

尝试在解决方案资源管理器中为这些程序集设置“复制本地”,并确保将它们放入绑定日志中指定的文件夹中。

此外,它们可能是使用V2 CLR构建的。如果是,则必须通过将其添加到您的web / app config

来启用混合模式绑定
<configuration>
   <startup  useLegacyV2RuntimeActivationPolicy="true">
       <supportedRuntime version="v4.0"/>
  </startup>
</configuration> 

答案 4 :(得分:2)

为了解决这个问题,我通过运行以下命令并检查结果来确保我的所有项目都使用相同的版本:

update-package Newtonsoft.Json -reinstall

最后,我从web.config中删除了以下内容:

  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
  </dependentAssembly>

答案 5 :(得分:2)

我知道这是一个老问题,但在搜索有关Visual Studio中部分绑定错误的解决方案时,似乎仍然是一个流行的结果。我遇到了与原始海报非常相似的问题,但是使用EntityFramework.dll和Visual Studio 2015(.ASP Web Forms项目),我找到的解决方案涉及一个广泛的问题。由于我没有找到与我的解决方案类似的任何答案,我认为贡献我发现的内容可能会有所帮助,我希望它确实有助于某人。

在我的web.config中,我冒充了一个服务帐户的域用户。此服务帐户无法访问我的临时文件文件夹,因此在调试时,它无法将dll复制到那里,因此无法加载它们。

我们最终发现了什么,并且正在查看错误消息中提到的临时文件夹。在上面的原始问题中,您会注意到这些行&#34;尝试下载新的URL文件:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files .. &#34;当我查看该文件夹时,我的DLL不在那里。

我的解决方案是这样的:因为我使用64位环境,并冒充域帐户,我将域服务帐户用户添加到我的本地C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP具有写入(和修改 - 用于良好测量)访问的.NET Files文件夹。

底线 - 确保您的Temp文件夹授予您的应用运行用户的写访问权。

答案 6 :(得分:1)

我在尝试从Visual Studio运行Web应用程序时遇到错误,但在我的情况下答案很简单。当我仔细阅读异常时,我可以看到应用程序不再使用有问题的程序集,但副本仍在bin文件夹中。删除违规装配后,错误消失了。

答案 7 :(得分:1)

在我的情况下,我浏览了我的网站并用新名称替换了网站的名称。我无意中将'PreviousWebSiteName'替换为Web.config中的'NewWebSiteName',其中指定了程序集名称。

    <pages enableSessionState="false" enableViewStateMac="true" enableEventValidation="true" controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID">
  <controls>
    <add assembly="NewWebSiteName" namespace="App_Code.Controls" tagPrefix="blog" />
  </controls>
</pages>

该网站仍在使用旧名称构建程序集 - 我只打算更改网站页面上显示的网站名称;我不需要在内部改变任何东西。恢复我的命名更改之前的Web.config条目(导致与构建的程序集的名称匹配的条目)为我解决了错误。

答案 8 :(得分:1)

这是一个古老的问题,但是当我今天遇到同样的问题时,它仍然是最高的结果。我已将Visual Studio中的项目编译切换为目标x64,而不是“所有CPU”(在64位计算机上)。根据其他答案,将有两种修复方法-将所有内容更改为32位或全部更改为64位。在这种情况下,我需要64位。

KabanaSoft's answer非常适合我。从Visual Studio 15.6.6开始仍然正确。

答案 9 :(得分:0)

在我的情况下,我的web.config中有一些废话,特别是一个半注释掉的httpHandler,一旦我清理了它,我的绑定问题就消失了。