View Single Post
  #5 (permalink)  
Old February 11th, 2011, 12:05 PM
flyinhawaiian flyinhawaiian is offline
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default

This is the actual error you'll encounter when you do an action that tries to access the database. If you're hitting the server from another machine, you'll get a different message that hides all the details (for security reasons). So, you have to hit the NerdDinner url on the server itself... go to the physical server and try to access http://localhost/NerdDinner. Then try to find a dinner.

Quote:
Server Error in '/NerdDinner' Application.
--------------------------------------------------------------------------------

Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.
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.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.

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.
Exception occurs in PaginatedList.cs. While debugging you'll see "The underlying provider failed on Open."
Code:
public PaginatedList(IQueryable<T> source, int pageIndex, int pageSize)
{
	PageIndex = pageIndex;
	PageSize = pageSize;
	TotalCount = source.Count(); // <--- DIES RIGHT HERE.
	TotalPages = (int)Math.Ceiling(TotalCount / (double)PageSize);
	this.AddRange(source.Skip(PageIndex * PageSize).Take(PageSize));
}
Using the call stack, you can back track to DinnersController.cs
Code:
public ActionResult Index(int page = 0)
{
    const int pageSize = 10;

    var upcomingDinners = dinnerRepository.FindUpcomingDinners();

    var paginatedDinners = new PaginatedList<Dinner>(upcomingDinners, page, pageSize); // <-- exception 

    return View(paginatedDinners);
}
upcomingDinners comes from the repository (DinnerRepository.cs) method FindUpcomingDinners() which tries to select data from a NerdDinnerEntities object.

So somehow the connection string isnt right when NerdDinnerEntities is instantiated.
Code:
private NerdDinnerEntities entities = new NerdDinnerEntities();

Last edited by flyinhawaiian; February 11th, 2011 at 12:25 PM..