[英]SignalR 2.0 error: Could not load file or assembly Microsoft.Owin.Security
I'm following this tutorial step by step 我正在逐步学习本教程
http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/tutorial-signalr-20-self-host http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/tutorial-signalr-20-self-host
And I'm getting an exception on the line marked below 而且我在下面标出的行上有例外
string url = "http://localhost:8080";
using (WebApp.Start(url)) //<------ error on this line
{
Console.WriteLine("Server running on {0}", url);
Console.ReadLine();
}
Error message: 错误信息:
Could not load file or assembly 'Microsoft.Owin.Security, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. 无法加载文件或程序集“Microsoft.Owin.Security,Version = 2.0.1.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35”或其依赖项之一。 The located assembly's manifest definition does not match the assembly reference. 定位的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040) (HRESULT异常:0x80131040)
More info: 更多信息:
In my project solution, the reference is pointing to the dll in the packages folder from NuGet 在我的项目解决方案中,引用指向NuGet的packages文件夹中的dll
This has been added in my App.config file by NuGet 这已由NuGet添加到我的App.config文件中
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
In the packages folder, packages\\Microsoft.Owin.Security.2.0.0\\lib\\net45
, the file version of Microsoft.Owin.Security.dll is 2.020911.395 在packages文件夹packages\\Microsoft.Owin.Security.2.0.0\\lib\\net45
,Microsoft.Owin.Security.dll的文件版本是2.020911.395
Ok I've solved it. 好的,我已经解决了。
I had to upgrade my Microsoft.Owin.Security package to 2.1.0 with this command 我不得不使用此命令将Microsoft.Owin.Security包升级到2.1.0
Install-Package Microsoft.Owin.Security -Version 2.1.0
And modify the bindings in my App.config like this 并修改我的App.config中的绑定
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
In my case, I had two projects: 就我而言,我有两个项目:
MyProj.MvcWeb
(an MVC application that referenced Microsoft.Owin.Security 3.0.0
) MyProj.MvcWeb
(引用Microsoft.Owin.Security 3.0.0
的MVC应用程序) MyProj.Data.Entities
(a class library that referenced Microsoft.Owin.Security 2.1.0
; not sure how this happened) MyProj.Data.Entities
(引用Microsoft.Owin.Security 2.1.0
类库;不确定这是怎么发生的) Upgrading Microsoft.Owin.Security
from 2.1.0
to 3.0.0
in the MyProj.Data.Entities
project fixed the issue for me. 在MyProj.Data.Entities
项目MyProj.Data.Entities
Microsoft.Owin.Security
从2.1.0
升级到3.0.0
为我解决了这个问题。
I took your idea, thanks for the research you did, and I did it like this: 我接受了你的想法,谢谢你所做的研究,我做到了这样:
get-project PerfSurf | Update-Package Microsoft.Owin.Security
It's much more simpler, and this will update manifest itself. 它更简单,这将更新清单本身。
Ignore this ( get-project PerfSurf
) part, as I use it because I have multiple test project and don't want to update them all 忽略这个( get-project PerfSurf
)部分,因为我使用它,因为我有多个测试项目,并且不想更新它们全部
Simple, Go to your web.config file. 很简单,转到web.config文件。 Change the "bindingRedirect" tag for Microsoft.Owin, Microsoft.Owin.Security.OAuth, Microsoft.Owin.Security.Cookies, Microsoft.Owin.Security to as follows: 将Microsoft.Owin,Microsoft.Owin.Security.OAuth,Microsoft.Owin.Security.Cookies,Microsoft.Owin.Security的“bindingRedirect”标记更改为如下所示:
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.1.0" />
this could work. 这可行。
in my case, it turned out to be IIS express issue. 在我的情况下,它原来是IIS快递问题。 Once i changed debug to Local IIS, error was gone. 一旦我将调试更改为本地IIS,错误就消失了。
Renaming app.config to web.config works for me. 将app.config重命名为web.config对我有用。 Or just make a copy of app.config and call it web.config 或者只是复制app.config并将其命名为web.config
In my case, I have this error in code first during "update database". 在我的情况下,我在“更新数据库”期间首先在代码中出现此错误。 I put "Set a as startUp a Project" in project with migration.it helped me 我在项目中将“设置为启动项目”设置为migration.it帮助了我
I fixed it by changing my Web.config configuration tag: 我通过更改我的Web.config配置标记来修复它:
from this: 由此:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
to this: 对此:
<configuration>
dont know why this works. 不知道为什么会这样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.