我正在遵循洋葱体系结构,并在DependencyResolution项目中使用simple injector
。这是我的架构:
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
- My AngularJs App
5-Test
- Test Project
StartUp.cs
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
// Here I am getting error at runtime.
SimpleInjectorInitializer.Initialize(app);
ConfigureAuth(app);
}
}
SimpleInjectorInitializer.Initialize
public static Container Initialize(IAppBuilder app)
{
var container = GetInitializeContainer(app);
// This is an extension method from the integration package.
container.RegisterWebApiControllers(GlobalConfiguration.Configuration);
container.Verify();
GlobalConfiguration.Configuration.DependencyResolver =
new SimpleInjectorWebApiDependencyResolver(container);
return container;
}
在这里,我添加了对引用自WebApi项目的System.Web, System.Web.Http, System.Web.Http.Host
的引用。
我将DependencyResolution项目的输出路径放入WebApi bin,并在web.config
中设置owinstart的值。
这是我得到的错误:
类型“ System.IO.FileLoadException”的异常发生在
Infrastructure.DependencyResolution.dll,但未在用户中处理
码
附加信息:无法加载文件或程序集
'System.Web.Http,版本= 4.0.0.0,文化=中性,
PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。的
定位的程序集的清单定义与程序集不匹配
参考。 (来自HRESULT的异常:0x80131040)
编辑:
这是App.Config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For 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>
参考方案
您可能在应用程序的配置文件中缺少绑定重定向。在大多数情况下,NuGet程序包管理器会为您正确设置绑定重定向,有时可能会这样做。
您在配置文件中所需的绑定重定向如下所示:
<?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>
请注意,您需要将{version}
占位符替换为您所引用的实际版本。
有没有一种方法可以使div上的click事件与表单环境中的单选按钮相同?我只希望下面的div提交值,单选按钮很丑代码输出如下:<input id="radio-2011-06-08" value="2011-06-08" type="radio" name="radio_date…
将python scikit学习模型导出到pmml - python我想将python scikit-learn模型导出到PMML。哪个python软件包最合适?我阅读了有关Augustus的内容,但是我无法使用scikit-learn模型找到任何示例。 python大神给出的解决方案 SkLearn2PMML是 JPMML-SkLearn命令行应用程序周围的薄包装。有关受支持的Scikit-Learn Estimator和…
如何在使用HTML5 Web Audio API的音频可视化程序上实现音频控件? - javascript我知道在导入音频源时如何放置音频控件,如下所示: <audio src="audio.mp3" id="audio" controls="true"></audio> 我试图摆弄的音频可视化器的不同之处在于,它使用了音频,用户必须上载(测试下面的演示)。我想知道的是-如何放置…
如何使用PHP从动态输入字段捕获数组值? - javascript我正在编写一个在线时间跟踪网页,允许用户将学习时间输入该系统。用户将首先输入名称,然后根据日期输入学习时间。一天中可能会有多个学习时间。以下是我第一页的编码,<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"…
SOAPFaultException部署在Tomcat上时,但在GlassFish中工作正常 - java朋友们,我一直在尝试很多,阅读了很多论坛,但无法理解为什么出现此问题。我使用契约优先方法创建了一个Jax-WS WebService。创建WSDL和XSD,然后使用wsimport工具生成其余工件,为SEI提供实现。将WebService应用程序部署到Eclipse Helios中的GlassFish(Glassfish适配器和Eclipse中安装的插件)。…