no parameterless constructor defined for this object after deployment on DMZ server

605 views
Skip to first unread message

Sachin...@phila.gov

unread,
Oct 29, 2018, 10:50:04 AM10/29/18
to structuremap-users
Hi ,

I have below implementation (code) of structure map into my project with MVC5. 


public class HomeController : Controller

    {

        ILog logger = LogManager.GetLogger(typeof(HomeController));  

 

        private readonly IUserService _userService;

        private readonly ITaxPayerService _taxpayerService;

 

        public HomeController(IUserService userService, ITaxPayerService taxpayerService)

        {

            _userService = userService;

            _taxpayerService = taxpayerService;

        }

 

        [Authorize]

        public ActionResult TestPage()

        {

            var users = new List<User>();

            try

            {

                users = _userService.GetAllUsers().ToList();

            }

            catch (Exception ex)

            {

                logger.Error(ex.ToString());

            }

            return View(users);

        }

       

        [AllowAnonymous]

        public ActionResult Index()

        {

            //IEnumerable<User> LUsrp = new IEnumerable<User>();

            //LUsrp = UsrService.getAllUsersPassword();

 

            //IList<User> LUsr = new List<User>();

            //LUsr = UsrService.GetUsers();

 

 

            //User usr = new Models.User();

            //usr = UsrService.GetUserById("Sachin.Pawar");

           

            return View();

        }

 

        [AllowAnonymous]

        public ActionResult About()

        {

            ViewBag.Message = "Your application description page.";

 

            return View();

        }

 

        [AllowAnonymous]

        public ActionResult Contact()

        {

            ViewBag.Message = "Your contact page.";

 

            return View();

        }

       

    }



I can not have simple parameterless constructor , I need parameterized constructor for my project functionality implementation.

Above mentioned code works fine with Development environment , Staging environment But when I deploy same code base into DMZ server . It gives me error "No parameterless constructor defined for this object". 



Below are the stack trace details.


Server Error in '/e3' Application.

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. 

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

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[MissingMethodException: No parameterless constructor defined for this object.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +139
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +105
   System.Activator.CreateInstance(Type type) +12
   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +75

[InvalidOperationException: An error occurred when trying to create a controller of type 'PT.Web.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.]
   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +242
   System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +103
   System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +263
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +77
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +1020
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +128


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3163.0




Then only difference from staging server and dmz server is "DMZ server" does not have internet connection. Except this no single difference. I have compared and  verified all the installed component from both server. 
I was wondering , if it require the parameter less constructor then how come its working in development and staging environment.


Please help , I am lost .

Sachin

Jeremy Miller

unread,
Oct 29, 2018, 11:00:10 AM10/29/18
to structure...@googlegroups.com
You don’t have StructureMap integrated into your MVC project so it’s not being used at all. Notice that there’s nothing about StructureMap itself in the stack trace and that’s a standard MVC exception trying to build out controllers with its default ControllerActivator.

--
You received this message because you are subscribed to the Google Groups "structuremap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to structuremap-us...@googlegroups.com.
To post to this group, send email to structure...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/structuremap-users/e0873810-6de3-4b32-82c7-93b8af5fe7e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sachin...@phila.gov

unread,
Oct 29, 2018, 11:27:42 AM10/29/18
to structuremap-users
Hi Jeremy,

Thanks for reply, Below is the screenshot about structuremap implementation. 

errordms.png


To unsubscribe from this group and stop receiving emails from it, send an email to structuremap-users+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to structuremap-users+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to structuremap-users+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages