0

I just got this strange problem when I run locally and if I click on a link that takes me to controller X it works but after publishing it to windows azure I get this error when clicking the same link:

An error occurred when trying to create a controller of type 'Prodject.Controllers.ControllerX'. Make sure that the controller has a parameterless public constructor.

Same goes for all other links that takes me to that specific controller any ideas?

Not sure how much more info I can give since this is the only information I think I can get a hold off.

And no it's not an API controller

Thank you for reading my post and taking your time to help me out!

ekad
  • 14,436
  • 26
  • 44
  • 46
Kladfizk
  • 99
  • 1
  • 17

2 Answers2

1

May be you have missed defining an parameterless contructor in some class(Used in the controller or the controller itself) where you have defined the contructor with parameter. And then try to instantiate the class without parameters.

Cijo V J
  • 261
  • 1
  • 3
  • 14
  • It is not mandatory to have `parameterless constructor` for class. It will get created automatically if it doesn't exists – Rahul Nikate May 25 '15 at 09:59
  • I thought it does need can you please explain these http://stackoverflow.com/questions/7230544/c-sharp-error-parent-does-not-contain-a-constructor-that-takes-0-arguments – Cijo V J May 25 '15 at 10:10
  • Parameterless constructor will get created only when there is not constructor defined at all for that class. Parameterless constructor will not get automatically created if class has parametered constructor already defined in class. – Rahul Nikate May 25 '15 at 10:16
  • 1
    Ok, I guess I was trying to explain same thing. – Cijo V J May 25 '15 at 10:20
  • 1
    Also now I realized that he said that when he tries to click that link the error occurs. Which means it is a run time error. And if at all he was missing a parameterless constructor it would throw him compile time error. Therefore this is not the solution for this problem – Cijo V J May 25 '15 at 10:27
0

Thanks to Rahul Nikate i found the problem there seems to have been an issue with the pathing for one of the classes constructors inside the controllerX, seams like Cijo V J was half right :)

Kladfizk
  • 99
  • 1
  • 17