Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Throw a better exception when the user didn't add the MVC services #347

Closed
danroth27 opened this issue Apr 29, 2014 · 8 comments
Closed

Comments

@danroth27
Copy link
Member

Currently you get an ArgumentNullException when you use MVC, but didn't add the MVC services. We should throw a better exception.

@yishaigalatzer
Copy link
Contributor

@dougbu - Here is the first replacement for enum support for this sprint

@rynowak
Copy link
Member

rynowak commented Apr 30, 2014

@davidfowl Had an earlier suggestion to auto-fix this problem for the user rather than throwing here. #128 #Demoware

@yishaigalatzer
Copy link
Contributor

We decided to throw and not autofix

-----Original Message-----
From: Ryan Nowak
Sent: 4/30/2014 11:34 AM
To: aspnet/WebFx
Cc: Yishai Galatzer
Subject: Re: [WebFx] Throw a better exception when the user didn't add the MVCservices (#347)

@davidfowl Had an earlier suggestion to auto-fix this problem for the user rather than throwing here. #128 #Demoware


Reply to this email directly or view it on GitHub.

@yishaigalatzer yishaigalatzer added this to the Alpha milestone Apr 30, 2014
@yishaigalatzer yishaigalatzer assigned sornaks and dougbu and unassigned dougbu and sornaks May 5, 2014
@yishaigalatzer yishaigalatzer modified the milestones: Post Alpha, Alpha May 14, 2014
@yishaigalatzer yishaigalatzer removed this from the Post Alpha milestone May 23, 2014
@dougbu
Copy link
Member

dougbu commented Jul 28, 2014

Message already seems pretty good. Certainly not throwing an NRE now. Is this issue still relevant?

FYI message from Autofac, when using .NET 4.5:

The requested service 'Microsoft.AspNet.Mvc.IActionDescriptorsCollectionProvider' has not been
registered. To avoid this exception, either register a component to provide the service, check
for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an
optional dependency.

and from the default ServiceProvider, when using K10:

TODO: No service for type 'Microsoft.AspNet.Mvc.IActionDescriptorsCollectionProvider' has been
registered. 

@rynowak
Copy link
Member

rynowak commented Jul 28, 2014

@dougbu this still isn't good enough. It doesn't tell the user what to do to fix the problem.

Did you call UseServices()? Did you call AddMvc()? Did you call .UseMvc()? you should do that.

@dougbu
Copy link
Member

dougbu commented Jul 28, 2014

My question was really about balancing that usability improvement (which seems slight) against breaking the preferred DI model and explicitly calling serviceProvider.GetService<IActionDescriptorsCollectionProvider>() from the DefaultActionSelector constructor.

@yishaigalatzer
Copy link
Contributor

Same as #543

@yishaigalatzer yishaigalatzer added this to the 6.0.0-alpha4 milestone Jul 28, 2014
sornaks pushed a commit that referenced this issue Aug 21, 2014
… services.

Introducing MarkerService for identifying if MvcServices were added.
@sornaks
Copy link

sornaks commented Aug 21, 2014

Checked in. 791518d

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants