没有为此对象定义的无参数构造函数 [英] No parameterless constructor defined for this object
本文介绍了没有为此对象定义的无参数构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发visual studio 2013并安装了ninject.mvc5以及
我这样映射了
Hi,
I am working on visual studio 2013 and installed ninject.mvc5 and also
I have mapped like this
private static void RegisterServices(IKernel kernel)
{
kernel.Bind<ITrainService>().To<TrainService>();
}
但我仍然收到错误'没有为此对象定义无参数构造函数。
我还修改了web.config,如
But I am still getting error 'No parameterless constructor defined for this object.
I have also modified web.config like
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="5.2.2.0" />
<bindingRedirect oldVersion="2.0.0.0" newVersion="5.2.2.0" />
<bindingRedirect oldVersion="3.0.0.0" newVersion="5.2.2.0" />
<bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>
但仍然没有运气
任何帮助??
But still no luck
Any help ??
推荐答案
无参数构造函数是很明显的原因是许多技术所需要的。当然,有一个默认的构造函数,但是,如果你定义了一些其他的构造函数,它只有在你明确定义它时才可用。而已。明确定义无参数构造函数。
-SA
A parameterless constructor is required in a number of technologies, by a pretty apparent reason. Of course, there is a default constructor, but, if you define some other constructor(s), it will become available only if you explicitly define it. That's it. Define a parameterless constructor explicitly.
—SA
此问题已解决。实际上我在另一个项目中创造了区域。所以我在父项目中配置Ninject而不是在子项目中进行。
This problem is solved . Actually I had made area in another project. so I configured Ninject in parent project instead of doing it in child project.
这篇关于没有为此对象定义的无参数构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文