Problem running PTracker for MVC eBook

Problem running PTracker for MVC eBook

Old forum URL: forums.lhotka.net/forums/t/10417.aspx


CyclingFoodmanPA posted on Monday, June 06, 2011

I am not sure why I keep getting this error and what is causing it.  Here it is:

System.Reflection.TargetInvocationException was unhandled by user code
  Message=Exception has been thrown by the target of an invocation.
  Source=mscorlib
  StackTrace:
       at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
       at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
       at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
       at System.Activator.CreateInstance(Type type, Boolean nonPublic)
       at System.Activator.CreateInstance(Type type)
       at ProjectTracker.Dal.DalFactory.GetManager() in E:\Development\Training\CSLAeBooks\06-AspMvc-110518\06-AspMvc-110518\NET\cs\ProjectTracker\ProjectTracker.Dal\DalFactory.cs:line 22
       at ProjectTracker.Library.Security.PTIdentity.DataPortal_Fetch(UsernameCriteria criteria) in E:\Development\Training\CSLAeBooks\06-AspMvc-110518\06-AspMvc-110518\NET\cs\ProjectTracker\ProjectTracker.Library\Security\PTIdentity.cs:line 27
       at lambda_method(Closure , Object , Object[] )
       at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters)
  InnerException: System.Data.EntityException
       Message=The underlying provider failed on Open.
       Source=System.Data.Entity
       StackTrace:
            at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
            at System.Data.EntityClient.EntityConnection.Open()
            at Csla.Data.ObjectContextManager`1..ctor(String connectionString, String label)
            at Csla.Data.ObjectContextManager`1.GetManager(String database, Boolean isDatabaseName, String label)
            at Csla.Data.ObjectContextManager`1.GetManager(String database, Boolean isDatabaseName)
            at Csla.Data.ObjectContextManager`1.GetManager(String database)
            at ProjectTracker.DalEf.DalManager..ctor() in E:\Development\Training\CSLAeBooks\06-AspMvc-110518\06-AspMvc-110518\NET\cs\ProjectTracker\ProjectTracker.DalEf\DalManager.cs:line 27
       InnerException: System.Data.SqlClient.SqlException
            Message=A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
            Source=.Net SqlClient Data Provider
            ErrorCode=-2146232060
            Class=20
            LineNumber=0
            Number=-1
            Server=""
            State=0
            StackTrace:
                 at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
                 at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
                 at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity)
                 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.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
            InnerException:

It happens when I run the app and select Projects or when I try to log in.  I know the original PTracker had user id "pm" and password "pm" and "admin"/"admin", etc.  But I tried those and they do not work for the aspnetdb.mdf database.  Anyone have any ideas please?

Thank you in advance.

CyclingFoodmanPA

 

tmg4340 replied on Monday, June 06, 2011

Based on the error you're getting, you're not getting to the username/password verification yet.  "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections." means your MVC app can't find the SQL Server (or local MDF file) that you're trying to connect to.  I'd start with your DB connection string.

HTH

- Scott

CyclingFoodmanPA replied on Monday, June 06, 2011

You are spot on Scott.  I assumed (you know what happens when you ass-u-me) that the SQL Express connection string was correct but it wasn't.  The correct string was as follows:

 

 

<

 

 

add name="PTrackerEntities"
  connectionString="metadata=res://*/PTracker.csdl|res://*/PTracker.ssdl|res://*/PTracker.msl;provider=System.Data.SqlClient;provider connection string='data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\PTracker.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework'"providerName="System.Data.EntityClient" />

what the original string was.  A major ahh duh on my part.

Thanks Scott

Sometimes it is just a different view or set of eyes to straighten me out :)

Copyright (c) Marimer LLC