c# - Simple Injector Dependency Resolution Error -


i following onion architecture , using simple injector in dependencyresolution project. here architecture:

1-core      - domain classes      - repository interfaces      - service interfaces 2-infrastructure      - data      - dependency resolution      - repository interfaces implementation      - service interfaces implementation 3-webapi      - web api project 4-webclient      - angularjs app 5-test      - test project 

startup.cs

public partial class startup     {         public void configuration(iappbuilder app)         {             // here getting error @ runtime.             simpleinjectorinitializer.initialize(app);             configureauth(app);         }     } 

simpleinjectorinitializer.initialize

public static container initialize(iappbuilder app)         {             var container = getinitializecontainer(app);              // extension method integration package.             container.registerwebapicontrollers(globalconfiguration.configuration);              container.verify();              globalconfiguration.configuration.dependencyresolver =                 new simpleinjectorwebapidependencyresolver(container);              return container;         } 

here added reference system.web, system.web.http, system.web.http.host taken webapi project.

i put path of output of dependencyresolution project webapi bin , set value of owinstart in web.config.

here error getting:

an exception of type 'system.io.fileloadexception' occurred in infrastructure.dependencyresolution.dll not handled in user code

additional information: not load file or assembly 'system.web.http, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040)

edit:

here app.config:

<?xml version="1.0" encoding="utf-8"?> <configuration>   <configsections>     <!-- more information on entity framework configuration, visit http://go.microsoft.com/fwlink/?linkid=237468 -->   </configsections>   <runtime>     <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">       <dependentassembly>         <assemblyidentity name="microsoft.owin" publickeytoken="31bf3856ad364e35" culture="neutral" />         <bindingredirect oldversion="0.0.0.0-3.0.1.0" newversion="3.0.1.0" />       </dependentassembly>       <dependentassembly>         <assemblyidentity name="microsoft.owin.security" publickeytoken="31bf3856ad364e35" culture="neutral" />         <bindingredirect oldversion="0.0.0.0-3.0.1.0" newversion="3.0.1.0" />       </dependentassembly>       <dependentassembly>         <assemblyidentity name="microsoft.owin.security.cookies" publickeytoken="31bf3856ad364e35" culture="neutral" />         <bindingredirect oldversion="0.0.0.0-3.0.1.0" newversion="3.0.1.0" />       </dependentassembly>       <dependentassembly>         <assemblyidentity name="system.net.http.formatting" publickeytoken="31bf3856ad364e35" culture="neutral" />         <bindingredirect oldversion="0.0.0.0-5.0.0.0" newversion="5.0.0.0" />       </dependentassembly>       <dependentassembly>         <assemblyidentity name="system.web.http" publickeytoken="31bf3856ad364e35" culture="neutral" />         <bindingredirect oldversion="0.0.0.0-5.2.3.0" newversion="5.2.3.0" />       </dependentassembly>     </assemblybinding>   </runtime> </configuration> 

you missing binding redirect in application's configuration file. in cases, nuget package manager set binding redirects correctly you, fails so.

the binding redirect need in config file looks this:

<?xml version="1.0" encoding="utf-8"?> <configuration>   <runtime>     <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">       <dependentassembly>         <assemblyidentity name="system.web.http" publickeytoken="31bf3856ad364e35"              culture="neutral" />         <bindingredirect oldversion="0.0.0.0-{version}" newversion="{version}"/>       </dependentassembly>     </assemblybinding>   </runtime> </configuration> 

note need replace {version} placeholders actual version referencing.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -