如何配置StructureMap的asp.net MVC 5 [英] How to configure StructureMap for asp.net MVC 5

查看:254
本文介绍了如何配置StructureMap的asp.net MVC 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误。我安装它类似于asp.net的MVC 4。

I'm getting below error. I setup it similar to asp.net mvc 4.

此对象定义无参数的构造函数。说明:
  当前Web的执行过程中发生未处理的异常
  请求。请检查堆栈跟踪有关的详细信息
  错误以及它起源于code。

No parameterless constructor defined for this object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

异常详细信息:system.missingMethodException而:此对象定义无参数的构造函数

Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.

终于找到了实际的异常而试图获得类型的HomeController的情况下,发生激活错误键

Finally found the actual exception "Activation error occured while trying to get instance of type HomeController, key """

错误是发生在我打算注入服务类到户位指示

Error is occuring when i'm going to inject service class to the home contoller

推荐答案

感谢您对所有的答复终于发现了问题。
在我服务类我是指一个应用程序设置,但没有定义它的web.config文件,因为这structuremap的不能注入我的服务类的一个实例。

Thank you for all the reply finally found the issue. In my service class I refer a app setting but didn't define it on the web.config file because of that structuremap couldn't inject an instance of my service class.

private readonly string _path =
            ConfigurationManager.AppSettings["vp"].ToString(CultureInfo.InvariantCulture);

这篇关于如何配置StructureMap的asp.net MVC 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆