Patterns In Action throws exception when logging in

 
60   95.3
Aug 03, 2011
 

Hi:

I just downloaded the framework (.NET 4.0) and started the 'Patterns In Action' project.  Regardless of which presentation layer I use it throws an exception when I try to do the Login required by the program.  It crashes in file "ActionService.cs" in method "Login", line 81:

if (!Membership.ValidateUser(request.UserName, request.Password))

The exception is:

System.Data.SqlClient.SqlException was unhandled by user code
  Message=The database 'C:\MARKSSTUFF\MARS\DOFACTORY\PATTERNS IN ACTION\HOST.WCF.ACTIONSERVER\APP_DATA\ASPNETDB.MDF' cannot be opened because it is version 655. This server supports version 611 and earlier. A downgrade path is not supported.
Could not open new database 'C:\MARKSSTUFF\MARS\DOFACTORY\PATTERNS IN ACTION\HOST.WCF.ACTIONSERVER\APP_DATA\ASPNETDB.MDF'. CREATE DATABASE is aborted.
An attempt to attach an auto-named database for file C:\MarksStuff\Mars\DoFactory\Patterns In Action\Host.WCF.ActionServer\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
  Source=.Net SqlClient Data Provider
  ErrorCode=-2146232060
  Class=20
  LineNumber=65536
  Number=948
  Procedure=""
  Server=\\.\pipe\4C1D8742-0D2B-48\tsql\query
  State=1
  StackTrace:
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
       at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)
       at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
       at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
       at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.SqlClient.SqlConnection.Open()
       at System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate)
       at System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation)
       at System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate)
       at System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat)
       at System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password)
       at System.Web.Security.Membership.ValidateUser(String username, String password)
       at ActionService.ServiceImplementations.ActionService.Login(LoginRequest request) in C:\MarksStuff\Mars\DoFactory\Patterns In Action\ActionService\ServiceImplementations\ActionService.cs:line 81
       at SyncInvokeLogin(Object , Object[] , Object[] )
       at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
       at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
  InnerException:


As described, I installed SQL Server Express.

Does anyone know what the problem might be?
Do I need to change my windows firewall?

Thanx,
Mark

PS - I also get an exception "System.Data.EntityException was unhandled by user code" when doing a search on the website. Again, I haven't yet "logged in".




800   99.9
Aug 03, 2011
Hello Mark:

I am sorry for the trouble.

I believe the exception shows what the issue is. It states: 

ASPNETDB.MDF cannot be opened because it is version 655. This server supports version 611 and earlier.
  A downgrade path is not supported
."

Basically, this means you have an old version of SQL Express installed. And it does not know how to deal with a more recent data file format.

I suggest you uninstall SQL Express from your machine and re-install a more recent SQL Express version.
That should do the trick.

Hope this helps.
Dan

108   96.6
Aug 04, 2011
Install SQL Express 2008. First uninstall the previous version or you will have to do some configuration in the project to look at whatever InstanceID you give the 2008 install.
 1 comment
 
Um, sorry, that's not the answer. I de-installed SQL Express 2008, and also the 2005 Version which I didn't realize was there. Then I re-installed, fresh, SQL Express 2008. For testing, I turned off the Windows Firewall. The exception, which occurs on exactly the same line as stated above (L. 81) is: System.Data.SqlClient.SqlException was unhandled by user code Message=Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed. Source=.Net SqlClient Data Provider ErrorCode=-2146232060 Class=14 LineNumber=65536 Number=15372 Procedure="" Server=.\SQLEXPRESS State=1 StackTrace: --- Mark Horowitz  Aug 05, 2011

60   95.3
Aug 05, 2011
Um, sorry, that's not the answer. I de-installed SQL Express 2008, and also the 2005 Version which I didn't realize was there. Then I re-installed, fresh, SQL Express 2008. For testing, I turned off the Windows Firewall.The exception, which occurs on exactly the same line as stated above (L. 81) is:

System.Data.SqlClient.SqlException was unhandled by user code
  Message=Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.
  Source=.Net SqlClient Data Provider
  ErrorCode=-2146232060
  Class=14
  LineNumber=65536
  Number=15372
  Procedure=""
  Server=.\SQLEXPRESS
  State=1
  StackTrace:

Regards, Mark
 1 comment
 
Check your web.config in the Hosting Layter. also make sure the version of Sql Express 2008 still has the InstanceID of SQLEXPRESS. I doubt it does since you already had SqlExpress 2005 and that is probabaly most definitely has the InstanceID of SqlExpress. Find out the instanceID and once you do you have to go to within Visual Studio Tools, Options and once options comes up drop down Database Tools then go to Data Connections and change your "Sql Server Instance Name (blank for default):" That should do it.I had the exact same issue. Once you do that double click on the .mdf files just to make sure you can open them and then start the solution. Worked for me. --- Dennis Tucker  Aug 05, 2011

108   96.6
Aug 05, 2011
Check your web.config in the Hosting Layer (default should still be "<add key="ConnectionStringName" value="EntityFramework.SqlExpress"/>". Also make sure the version of Sql Express 2008 still has the InstanceID of SQLEXPRESS. I doubt it does since you already had SqlExpress 2005 and that is probabaly most definitely has the InstanceID of SqlExpress. Find out the instanceID and once you do you have to go to within Visual Studio - Tools, Options and once options comes up drop down Database Tools then go to Data Connections and change "Sql Server Instance Name (blank for default):" That should do it.I had the exact same issue. Once you do that double click on the .mdf files just to make sure you can open them and then start the solution. Worked for me.

Thanks

60   95.3
Aug 05, 2011
Hmm, this is turning into a real problem.
- According to the "Sql Server Configuration Manager", SQL Server Services tab, I see "SQL Server (SQLEXPRESS).  So I assume that that is my InstanceID.  IS THIS THE TOOL, AND INSTANCE-ID, THAT YOU MEAN???
- In Tools -> Options -> Database Tools -> Data Connections I see "SQLEXPRESS"
- In the "web.config" file, I see the key "<add key="ConnectionStringName" value="EntityFramework.SqlExpress"/>" so that meets your spec.

Still, I get the exception!  I'm really sorry to be a pain in the butt and yes I'm a newbie to your tools but this must somehow work. I humbly ask for more help.  I have googled the issue but nothing really helped.

Regards,
Mark

 1 comment
 
Launch Sql Server Configuration Manager and go to &quot;SQL Server Services&quot; and you should see the Instance ID's under &quot;Name&quot;. the name should read &quot;SQL Server(InstanceIDOfYourInstances). Right now I am showing 3. Make sure it is also running. If it's not running right click and start it. Something else, right click the 2008 express version and go to properties and make sure &quot;Built-in Account: &quot; is selected and &quot;Local System&quot; is selected in the dropdown and restart the service. Make sure you restart. --- Dennis Tucker  Aug 05, 2011

60   95.3
Aug 08, 2011
Please see the image SQL-Server-Config-Manager, enclosed.  I just hope it's readable!
Regards,
Mark





 3 comments
 
In any case the basic error is always &quot;Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.&quot; --- Mark Horowitz  Aug 08, 2011
 
What I would do is uninstall sql express 2005 and install sql express 2008. That's what I had to do. --- Dennis Tucker  Aug 08, 2011
 
There is nothing more from SQL Express 2005 on my system, only 2008. In the Control-Panel's Uninstall program I see only Microsoft SQL Server 2008 (64-bit), Browser, Native Client, Setup Support Files, and VSS Writer, eg. 5 entries. --- Mark Horowitz  Aug 08, 2011

60   95.3
Aug 08, 2011
I found the problem:
I had to delete directory
C:\Documents and Settings\USERNAME\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS.
Remember to replace USERNAME with your username.

See
http://blog.laksha.net/2009/02/sql-express-error-failed-to-generate.html

Cheers,
Mark