[英]Autofac with Web Forms in VB.Net throwing MissingMemberException
I am trying to user Autofac in my Web Form application, using vb.net, I was following the examples in the Autofac site, but I am getting this error: 我想用户Autofac在我的Web窗体应用程序,使用vb.net,我下面的例子Autofac网站,但我得到这个错误:
An exception of type 'System.MissingMemberException' occurred in Microsoft.VisualBasic.dll but was not handled in user code. Microsoft.VisualBasic.dll中发生类型为'System.MissingMemberException'的异常,但未在用户代码中处理。 Additional information: Public member 'RegisterType' on type 'ContainerBuilder' not found.
附加信息:找不到类型为“ ContainerBuilder”的公共成员“ RegisterType”。
this is what I have defined in my Global.asax.vb: 这是我在Global.asax.vb中定义的:
Shared _containerProvider As IContainerProvider
Public ReadOnly Property ContainerProvider() As IContainerProvider Implements IContainerProviderAccessor.ContainerProvider
Get
Return _containerProvider
End Get
End Property
.... ....
' Build up your application container and register your dependencies.
Dim builder = New ContainerBuilder()
builder.RegisterType(Of CustomerService)().As(Of ICustomerService)()
builder.RegisterType(Of CustomerContactService)().As(Of ICustomerContactService)()
builder.RegisterType(Of UnitOfWork)().As(Of IUnitOfWork)()
' Once you're done registering things, set the container
' provider up with your registrations.
_containerProvider = New ContainerProvider(builder.Build())
this is what I have in my web.config: 这就是我的web.config中的内容:
<system.webServer>
<modules>
<add name="ContainerDisposal" type="Autofac.Integration.Web.ContainerDisposalModule, Autofac.Integration.Web" preCondition="managedHandler"/>
<add name="PropertyInjection" type="Autofac.Integration.Web.Forms.PropertyInjectionModule, Autofac.Integration.Web" preCondition="managedHandler"/>
<add name="AttributedInjection" type="Autofac.Integration.Web.Forms.AttributedInjectionModule, Autofac.Integration.Web" preCondition="managedHandler"/>
</modules>
</system.webServer>
and 和
<httpModules>
<!-- This section is used for IIS6 -->
<add name="ContainerDisposal" type="Autofac.Integration.Web.ContainerDisposalModule, Autofac.Integration.Web"/>
<add name="PropertyInjection" type="Autofac.Integration.Web.Forms.PropertyInjectionModule, Autofac.Integration.Web"/>
<add name="AttributeInjection" type="Autofac.Integration.Web.Forms.AttributedInjectionModule, Autofac.Integration.Web"/>
</httpModules>
I added all the references via nuget Autofac.Web 我通过nuget Autofac.Web添加了所有引用
What am I doing wrong? 我究竟做错了什么?
Try changing Dim builder = New ContainerBuilder()
to Dim builder As ContainerBuilder = New ContainerBuilder()
. 尝试将
Dim builder = New ContainerBuilder()
更改为Dim builder As ContainerBuilder = New ContainerBuilder()
。
The compiler does not recognize that your are calling an extension method without a strong type. 编译器无法识别您正在调用没有强类型的扩展方法。
Extension methods are not considered in late binding.
后期绑定中不考虑扩展方法。
MSDN: Extension Methods (Visual Basic) MSDN:扩展方法(Visual Basic)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.