programing

SignalR 2.0 error: Could not load file or assembly Microsoft.Owin.Security

telebox 2023. 9. 24. 12:46
반응형

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

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. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

More info:

In my project solution, the reference is pointing to the dll in the packages folder from NuGet

This has been added in my App.config file by NuGet

<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>

패키지 폴더에서,packages\Microsoft.Owin.Security.2.0.0\lib\net45, 마이크로소프트사의 파일 버전오윈. 보안.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

Install-Package Microsoft.Owin.Security -Version 2.1.0

And modify the bindings in my App.config like this

<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(참조한 MVC 애플리케이션)Microsoft.Owin.Security 3.0.0)
  • MyProj.Data.Entities(참조한 클래스 라이브러리)Microsoft.Owin.Security 2.1.0; 어떻게 이런 일이 일어났는지 확실하지 않음)

업그레이드중Microsoft.Owin.Security부터2.1.0로.3.0.0에서MyProj.Data.Entities프로젝트가 저를 위해 문제를 해결했습니다.

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.

무시()get-project PerfSurf) 부분, 여러 테스트 프로젝트가 있어서 전부 업데이트하고 싶지 않아서 사용하고 있습니다.

Simple, Go to your web.config file. Change the "bindingRedirect" tag for Microsoft.Owin, Microsoft.Owin.Security.OAuth, Microsoft.Owin.Security.Cookies, Microsoft.Owin.Security to as follows:

<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.1.0" />

this could work.

This assembly does not match what was requested that is why you get this error. check the Microsoft.Owin.Security version in the GAC. Also see here

in my case, it turned out to be IIS express issue. Once i changed debug to Local IIS, error was gone.

Renaming app.config to web.config works for me. Or just make a copy of app.config and call it 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

Web.config 구성 태그를 변경하여 수정했습니다.

이 내용으로부터:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

다음 항목에 대해:

<configuration>

이것이 왜 작동하는지 모릅니다.

언급URL : https://stackoverflow.com/questions/22060716/signalr-2-0-error-could-not-load-file-or-assembly-microsoft-owin-security

반응형