gpt4 book ai didi

c# - SignalR 和 c# 导致版本错误

转载 作者:行者123 更新时间:2023-11-30 17:55:36 25 4
gpt4 key购买 nike

我刚刚安装了 SignalR 并收到以下错误。看起来好像我遇到了版本问题,但我不知道在哪里修复它。我已经使用 NuGet 安装程序安装了 SignalR。

有人知道如何解决这个问题吗?

Could not load file or assembly 'Microsoft.Owin.Host.SystemWeb, Version=0.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Owin.Host.SystemWeb, Version=0.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Source Error:


Line 35: protected void Session_Start(Object sender, EventArgs e)
Line 36: {
Line 37: RouteTable.Routes.MapHubs();
Line 38: }
Line 39: }

未捕获的类型错误:无法读取未定义的 signalR_test.html:35 的属性“客户端”

  <!--Script references. -->
<script src="../Scripts/jquery-1.9.1.js"></script>
<script src="../Scripts/jquery.signalR-1.0.0-rc1.js"></script>
<script src="../Scripts/jquery.signalR-1.0.0-rc1.min.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="/signalr/hubs"></script>

<!--Add script to update the page and send messages.-->
<script type="text/javascript">
$(function () {
// Declare a proxy to reference the hub.
var chat = $.connection.CollaboratorHub;
// Create a function that the hub can call to broadcast messages.
chat.client.broadcastMessage = function (name, message) {
// Html encode display name and message.

--包。

<packages>
<package id="EntityFramework" version="5.0.0" targetFramework="net45" />
<package id="jQuery" version="1.8.2" targetFramework="net45" />
<package id="jQuery.UI.Combined" version="1.8.11" targetFramework="net45" />
<package id="jQuery.Validation" version="1.9.0.1" targetFramework="net45" />
<package id="knockoutjs" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Providers.Core" version="1.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Providers.LocalDB" version="1.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="2.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.SignalR" version="1.0.0-rc1" targetFramework="net45" />
<package id="Microsoft.AspNet.SignalR.Core" version="1.0.0-rc1" targetFramework="net45" />
<package id="Microsoft.AspNet.SignalR.JS" version="1.0.0-rc1" targetFramework="net45" />
<package id="Microsoft.AspNet.SignalR.Owin" version="1.0.0-rc1" targetFramework="net45" />
<package id="Microsoft.AspNet.SignalR.SystemWeb" version="1.0.0-rc1" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="4.0.20505.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="4.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.20710.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" targetFramework="net45" />
<package id="Microsoft.jQuery.Unobtrusive.Ajax" version="2.0.20505.0" targetFramework="net45" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="2.0.20505.0" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="1.0.0-rc1" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Modernizr" version="2.6.2" targetFramework="net45" />
<package id="Newtonsoft.Json" version="4.5.9" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="WebGrease" version="1.1.0" targetFramework="net45" />
</packages>

使用地点:AlumCloud

最佳答案

对我来说,这听起来像是问题是你正在使用一些依赖于特定版本的 Microsoft.Owin.Host.SystemWeb 的程序集:即版本 X,但是 Microsoft.Owin.Host.SystemWeb 的版本越来越加载的是版本 Y。默认情况下,CLR 将为此引发错误。

您可以通过确保始终使用一个版本(例如 X)并且所有依赖程序集都引用该版本来解决此问题。

您可能需要查看 ildasm/reflector 中的所有程序集,以准确了解它们尝试加载的版本。

或者,您可以尝试使用 assembly binding redirect 来强制 CLR 接受不同的程序集版本。它对 CLR 说“当某些程序集要求版本 X 时加载版本 Y”。即使您尝试这样做,您的应用也只有在程序集公共(public)接口(interface)没有发生变化的情况下才会成功。

(注意 1,我无法从你的问题中判断它是在哪里找到 Microsoft.Owin.Host.Systemweb 的,但由于缺乏进一步的信息,我假设它是应用程序 bin 文件夹,并且它不会影响答案,但是它确实妨碍了调试版本不匹配。)

关于c# - SignalR 和 c# 导致版本错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14905444/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com