2014-04-29 3 views
3

새로운 asp mvc 5 프로젝트를 만들었습니다.
프로젝트 대상 .NET.
ninject mvc 3 nuget 패키지가 설치되었습니다. 하지만 내가 CreateKernel() 방법 NinjectWebCommon.cs에서이 오류가 프로젝트를 실행할 때 다음 Ninject.MVC이 assebly ASP.NET MVC 어셈블리의 이전 버전을 참조하고 있기 때문에mvc 5 프로젝트에 ninject mvc 3을 설치 한 후의 문제

An exception of type 'System.IO.FileLoadException' occurred in Ninject.dll but was not handled in user code

Additional information: Could not load file or assembly 'System.Web.Mvc, Version=3.0.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)

+0

왜 Ninject.MVC5를 설치하지 않습니까? http://www.nuget.org/packages/Ninject.MVC5/ – devuxer

답변

3

이 오류를 얻을 수 있습니다. 강하게 입력되었으므로 최신 어셈블리를 사용하도록 응용 프로그램에 알려야합니다.

<runtime> 
    <dependentAssembly> 
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
    <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> 
    </dependentAssembly> 
</runtime> 

당신은 당신의 구성이를 추가하거나 Ninject package 새로운 사용할 수 있습니다 : 기본 프로젝트 템플릿의 web.config 파일과 같은 런타임 섹션을 포함하는 이유입니다.

+0

새 프로젝트를 만들고'Ninject.MVC5'를 설치하면 작동합니다. 그러나 내가 실수 한 프로젝트에서 모든 프로젝트 파일을 제거하고'Ninject.MVC5'를 설치했지만 같은 오류가 발생했습니다. 어떻게 든 프로젝트를 어떻게 정리해야합니까? 나는 전체 솔루션을 재구성하려고 노력했지만 여전히 동일합니다. – 1110

+0

@ 1110 web.config에 System.Web.Mvc의 dependentAssembly 항목이 있습니까? –

+0

아니요.하지만 지금 추가하고 오류가 발생합니다. '파일 또는 어셈블리'System.Web.Mvc '또는 해당 종속성 중 하나를로드 할 수 없습니다. 찾은 어셈블리의 매니페스트 정의가 어셈블리 참조와 일치하지 않습니다. (Exception from HRESULT : 0x80131040)' – 1110

3

응용 프로그램 webconfig 파일에이 내용을 포함하십시오.

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 

<runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
      <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
      <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
</runtime>