This project is read-only.

Exception attempting to access db.Dinners

Sep 13, 2011 at 7:59 PM

I've installed the NerdDinner project using the latest version of the source code (for MVC 3), successfully compiled it and can bring up the home page.  However, if I try to create a dinner or list all dinners, I get this message below.  Any ideas?  I am running on Windows 7 and SQL Server Express SP2.  I thought this might be related to the issue with the mismatched version of the NerdDinner.mdf, so I created a new database, populated it with data, took it offline and replaced the files under App_Data with the new version.  Same result. 

Thanks for any help you can offer...

The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

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.IO.FileLoadException: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

Source Error:

Line 41:         public IQueryable<Dinner> All
Line 42:         {
Line 43:             get { return db.Dinners.Include(r => r.RSVPs); }
Line 44:         }
Line 45: 

Source File: C:\DevTest\mvc\NerdDinner\Trunk\NerdDinner\Models\DinnerRepository.cs    Line: 43

Sep 14, 2011 at 4:33 PM
Edited Sep 14, 2011 at 4:33 PM

Did you create the new database using the instructions from the discussion  If not, how did you create it?  The direct link to the blog post is

Sep 14, 2011 at 7:00 PM

Thanks for the response.  I created the database using scripts that I found in a couple of discussion posts.  Don't recall exactly where I got them.  I just used the direct link that you provided to create a new database and then made a couple of other changes. 

1. I created a new ASPNETDB using aspnet_regsql

2. I updated the connection strings to look like this:

  <add name="ApplicationServices" connectionString="data source=.\SQL2008;Integrated Security=SSPI;Initial Catalog=aspnetdb" providerName="System.Data.SqlClient" />
  <add name="NerdDinners" connectionString="data source=.\SQL2008;Integrated Security=SSPI;Initial Catalog=NerdDinner" providerName="System.Data.SqlClient" />

I continue to get the same error: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

Looking for a place to try a query early in the app, I added this code to the Application_Start handler:

            NerdDinner.Models.NerdDinners db = new Models.NerdDinners();
            var query = from d in db.Dinners
                        select d;

Same error.

Wait a minute.  As I was working on this response, I thought of the exception that the MiniProfilerPackage was throwing in the PreStart method.  I am new to this profiler and thought that the issue with the entity queries might be related.  So I commented out the WebActivator PreStart and PostStart calls and the issue with querying the database went away.  Seems the logging is throwing an exception and preventing the database access to succeed.  I'll dig deeper on this...

Thanks again!

Jan 13, 2012 at 8:38 PM
Edited Jan 14, 2012 at 11:28 PM


I was having same problem when I implemented NerdDinner on my localhost, using SQL Server 2008.

The solution to get NerdDinner up and running smootly is actually quite simple

I have download nerddinner-70027 and using trunk folder

Now just do these 3 steps and you will have NerdDinner up and running. 

1. download and install Microsoft® SQL Server® 2012 Express RC0 
from you may also download SQL Management Studio from same place. 

2. now just open NerdDinner (in Visual Studio (I'm using 2010)) and open web.config and connectionStrings.config
The connectionString inside these should point to your 2012 server instance name e.g.


    <add name="applicationservices" connectionString="data source=your-pc-name\your-sql-server-express-2012-name;integrated security=sspi;attachdbfilename=|datadirectory|aspnetdb.mdf;user instance=true" providerName="" />
    <add name="nerddinners" connectionString="data source=your-pc-name\your-sql-server-express-2012-name;integrated security=sspi;attachdbfilename=|datadirectory|nerddinner.mdf;user instance=true;multipleactiveresultsets=true" providerName="" />



Integrated Security=SSPI;
User Instance=True"

  <add name="NerdDinnerEntities"
            provider=System.Data.SqlClient;provider connection string=&quot;
            Data Source=Source=your-pc-name\your-sql-server-express-2012-name;
            Integrated Security=True;
            User Instance=True;

3. Open Server Explorer (inside VS) and right click mdf databases one by one, go to Modify Connection > klik Advanced button and change the DataSource to your 2012 sql server instance name

Thats it, you dont even have to commet-out your mini MiniProfiler code. Everything should run just smootly.