Re: [ninject] Ninject.Mvc3 Nuget Package - Getting "No parameterless constructor defined for this object."

574 views
Skip to first unread message

Bartelink, Ruben

unread,
Apr 5, 2013, 8:00:48 AM4/5/13
to nin...@googlegroups.com
Have little expertise in VB. Have had the good fortune of not spending a lot of time chasing Ninject.MVC3 problems so will try to help a bit by asking questions, here goes...

>1) Created a new "NinjectControllerFactory" and then my controllers loaded; however, none of my ActionFilters were injected properly

Are you using BindFilter (see the MVC wiki)?

2) Tried to set the DependencyResolver to the packaged NinjectDependencyResolver, but received "Entry point was not found" error

You didnt give the exact text but it suggests there may be confusion re binding redirects and/or multiple editions of the DLLs?

3) Removed all the ninject nuget packages and reinstalled them

Good to do; probably invalidates my previous point.

4) Checked the web.config assembly redirect bindings (I am redirecting everything from 0.0.0.0 - 4.0.0.0 to 4.0.0.0)

IIRC there is a .vb file either in a gist or linked from the docs I saw elsewhere - it may have something you missed (I recall seeing it late some night and had my 'I don't see the .vb blinkers set to pretty high at the time to be honest :D)

Ah, read your gist - the translation looks good.

At this point I'd be attaching a debugger and trapping on all exceptions - it seems like the 

DynamicModuleUtility.RegisterModule( typeof( NinjectHttpModule ) );

bit is not having it's effect - either execution isnt getting there or something in there is going wrong.

After that, I'd be looking in the source for the MVC/MVC3 extension to see where the SetDependencyResolver lives.

Also, I'd consider doing an include prelease NuGet update - there are some bugfixes stashed in there which may help you

Hope this helps a bit

--Ruben

On 4 April 2013 22:55, Rob Bihun <r...@robbihun.com> wrote:
I am using MVC 4 (.NET 4) in a VB web application that was upgraded from webforms. The only "non-standard" thing i'm doing is that i have all my controllers in a separate assembly that is also .NET 4 but is C#.

I installed the Nuget package "Ninject.Mvc3" and when i call a controller action i get "No parameterless constructor defined for this object."

I have read in the forms (and EVERYWHERE ELSE) that the nuget package sets up all the DependencyResolver actions for you (as well as some other things for mvc); however, this does not appear to be working for me.

I can create a new ControllerFactory and then my controllers load; however none of my ActionFilters (as designed in the ninject documentation) get called. I know this is not the right way to fix it and it should be working out of the box, i'm not quite sure what is "messed up" in this setup.

After I installed the Nuget Package, I deleted the NinjectWebCommon.cs file from the App_Start folder and created a new NinjectWebCommon.vb file and am initializing all the same calls in there.


Things I have tried to fix it:

1) Created a new "NinjectControllerFactory" and then my controllers loaded; however, none of my ActionFilters were injected properly
2) Tried to set the DependencyResolver to the packaged NinjectDependencyResolver, but received "Entry point was not found" error
3) Removed all the ninject nuget packages and reinstalled them
4) Checked the web.config assembly redirect bindings (I am redirecting everything from 0.0.0.0 - 4.0.0.0 to 4.0.0.0)

Any help or guidance is greatly appreciated.

--
You received this message because you are subscribed to the Google Groups "ninject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ninject+u...@googlegroups.com.
To post to this group, send email to nin...@googlegroups.com.
Visit this group at http://groups.google.com/group/ninject?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
--Ruben
Ruben Bartelink / +353 86 885 2399

Fred Chateau

unread,
May 1, 2013, 4:06:47 PM5/1/13
to nin...@googlegroups.com

> 4) Checked the web.config assembly redirect bindings (I am redirecting everything from 0.0.0.0 - 4.0.0.0 to 4.0.0.0)

 
Not having proper access to the version redirects is one thing that will result in the error you are receiving.

If your controllers are in a separate assembly (project) then I'm guessing you would have to do the version redirects in that project in an App.Config file. You may also have to do them in the Web project.

I didn't like the idea of using version redirects so I re-compiled Ninject.Web.Mvc to work directly with System.Web.Mvc. If you want a copy of the binary, let me know and I'll send you one.

Fred Chateau
Reply all
Reply to author
Forward
0 new messages