我将ASP.NET MVC 2 RC2源代码添加到我的解决方案中(使用这些说明:http://blog.stevensanderson.com/2009/02/03/using-the-aspnet-mvc-source-code-to-debug-your-app/),但现在由于Autofac的错误而无法构建。
The type 'System.Web.Mvc.IControllerFactory' is defined in an assembly
that is not referenced. You must add a reference to assembly
'System.Web.Mvc, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'.
我对MVC版本1的引用感到特别困惑。甚至在我添加MVC源代码之前,我使用的是MVC 2(来自二进制文件),而Autofac并没有抱怨。
答案 0 :(得分:1)
Autofac.Integration.Web程序集引用System.Web.Mvc。您没有说您正在使用哪个版本的Autofac,但是如果您乐意使用Autofac版本2(目前是测试版),则可以使用.NET 4构建。有关详细信息,请参阅http://code.google.com/p/autofac/issues/detail?id=162。
答案 1 :(得分:0)
正如eu-ge-ne所提到的,尝试装配绑定。我让Autofac 1.4在MVC 2 RC上运行得很好,尽管它被称为程序集。
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
我真的不能说为什么在你的解决方案中包含MVC项目而不是参考它会产生影响。