IIS SQL Server Compact 4.0 SP1 - c#

I've been using SQL Server Compact Edition 4.0 SP1 with Entity Framework for data access in one of our web applications for the past couple of years without problems, but in the last couple of days I've been getting errors when attempting to run the application locally from within IIS.
The error I'm getting is, unfortunately, not very helpful:
System.Data.SqlServerCe.SqlCeException: Unspecified error [ sqlcese40.dll ]
[EntityException: The underlying provider failed on Open.]
As I had just checked out a branch into a new directory, at first I thought the issue was caused by permissions, but granting the application pool read/write access did not fix it.
I tried a number of other things, uninstalling and reinstalling SQL Server CE etc... but this didn't fix the issue either.
Finally, I changed the "Enable 32-bit Applications" setting for the app pool to true and this "fixed" the issue and I was able to get the application running again.
I'm not satisfied with this solution however, as I've been running without this enabled for months without any problem and I want to figure out what has caused the issue but I'm a bit stumped as where to look next.
Just wondered if anyone had any suggestions?
Here is the full error from the Event Log:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 03/10/2016 12:39:00
Event time (UTC): 03/10/2016 11:39:00
Event ID: a0a208f33d6a4435a26d41aebf98e9a1
Event sequence: 2
Event occurrence: 1
Event detail code: 0
Application information:
Application domain:
Trust level: Full
Application Virtual Path:
Process information:
Process ID: 752
Process name: w3wp.exe
Account name: IIS APPPOOL\XXX
Exception information:
Exception type: EntityException
Exception message: The underlying provider failed on Open.
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 System.Data.Objects.ObjectContext.EnsureConnection()
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at System.Data.Entity.Internal.EdmMetadataRepository.QueryForModelHash(Func`2 createContext)
at System.Data.Entity.Internal.ModelCompatibilityChecker.CompatibleWithModel(InternalContext internalContext, ModelHashCalculator modelHashCalculator, Boolean throwIfNoMetadata)
at System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context)
at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)
Unspecified error [ sqlcese40.dll ]
at System.Data.SqlServerCe.SqlCeConnection.Open(Boolean silent)
at System.Data.SqlServerCe.SqlCeConnection.Open()
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
Request information:
Request URL: -
Request path: -
User host address: ::1
User:
Is authenticated: False
Authentication Type:
Thread account name: -
Thread information:
Thread ID: 7
Thread account name: -
Is impersonating: False
Stack trace: 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 System.Data.Objects.ObjectContext.EnsureConnection()
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at System.Data.Entity.Internal.EdmMetadataRepository.QueryForModelHash(Func`2 createContext)
at System.Data.Entity.Internal.ModelCompatibilityChecker.CompatibleWithModel(InternalContext internalContext, ModelHashCalculator modelHashCalculator, Boolean throwIfNoMetadata)
at System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context)
at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)

Related

How to debug SQL Server LINQ expressions? [duplicate]

This question already has answers here:
MSSQL Error 'The underlying provider failed on Open'
(31 answers)
Closed last year.
I have the following piece of code, which works at a customer, but not on my computer:
var result = await db.Configurations.FirstOrDefaultAsync().ConfigureAwait(false);
db is derived from a System.Data.Entity.DbContext, defined in EntityFramework.6.4.0\lib\net45\EntityFramework.dll.
In the corresponding SQL Server database, there is a table "Configurations" and it contains an entry.
When I launch the line of source code, an Exception gets generated (I hereby show the slightly formatted content of the immediate window while asking ? ex):
? ex
{"An exception occurred while initializing the database. See the InnerException for details."}
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233087
HelpLink: null
InnerException: {"The underlying provider failed on Open."}
Message: "An exception occurred while initializing the database. See the InnerException for details."
Source: "EntityFramework"
StackTrace: " bij System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)\r\n bij System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
bij System.Data.Entity.Internal.LazyInternalContext.<>c.<InitializeDatabase>b__58_0(InternalContext c)
bij System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input)
bij System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action)
bij System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
bij System.Data.Entity.Internal.InternalContext.Initialize()
bij System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
bij System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
bij System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
bij System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
bij System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
bij System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync[TSource](IQueryable`1 source)
bij Project.<GetConfigAsync>d__56.MoveNext() in C:\\Source_Code_Directory\\Source_Code_File.cs:regel 2149"
TargetSite: {Void PerformInitializationAction(System.Action)}
I know this line of code works at customer's system, and I'm working on a restored backup of customer's DB.
What is going wrong and what can I do to fix it (what is the underlying provider)?
Thanks in advance
In the meantime the problem is analysed:
I had taken the backup of the customer's DB and restored it on my PC, but the username, as indicated in the connectionstring in source code, was wrong, hence my application could simply not open the database connection, so now the problem comes down on a database user management issue.
Thanks for all the support.

SocketException being thrown when attempting to store sessionState in AppFabricCache for windows Azure webservice

I am attempting a simple example project to get to know how to configure a Windows Azure Cloud service to use Co-located caching.
I am using VS2010 and have followed this example but when I get to the end of the section on co-located caching, I cannot run my project locally. It worked fine when
I am getting the following exceptions: (I hope it's readable..)
Error in '/' Application.
The requested name is valid, but no data of the requested type was found
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.Net.Sockets.SocketException: The requested name is valid, but no data of the requested type was found
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.
Stack Trace:
[SocketException (0x2afc): The requested name is valid, but no data of the requested type was found]
Microsoft.ApplicationServer.Caching.AsyncResultNoResult.EndInvoke() +202
Microsoft.ApplicationServer.Caching.AsyncResult`1.EndInvoke() +40
Microsoft.ApplicationServer.Caching.SocketConnectionFactory.EndConnect(IAsyncResult asyncResult) +75
Microsoft.ApplicationServer.Caching.TcpClientChannelFactory.TcpConnectionCallback(IAsyncResult result) +182
[DataCacheException: ErrorCode:SubStatus:There is a temporary failure. Please retry later. (One or more specified cache servers are unavailable, which could be caused by busy network or servers. For on-premises cache clusters, also verify the following conditions. Ensure that security permission has been granted for this client account, and check that the AppFabric Caching Service is allowed through the firewall on all cache hosts. Also the MaxBufferSize on the server must be greater than or equal to the serialized object size sent from the client.). Additional Information : The client was trying to communicate with the server: net.tcp://SessionStateDemo:24233.]
Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ErrStatus errStatus, Guid trackingId, Exception responseException, Byte[][] payload, EndpointID destination) +767
Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody, EndpointID destination) +149
Microsoft.ApplicationServer.Caching.DataCacheFactory.EstablishConnection(IEnumerable1 servers, RequestBody request, Func3 sendMessageDelegate, DataCacheReadyRetryPolicy retryPolicy) +1313
Microsoft.ApplicationServer.Caching.<>c__DisplayClass5.b__2(RequestBody req) +198
Microsoft.ApplicationServer.Caching.SocketClientProtocol.SendReceive(IVelocityRequestPacket request, Func2 delegate, EndpointID& destination) +121
Microsoft.ApplicationServer.Caching.SocketClientProtocol.Initialize(IEnumerable1 servers) +1225
Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName, CreateNewCacheDelegate cacheCreationDelegate, DataCacheInitializationViaCopyDelegate initializeDelegate) +1104
Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName) +131
Microsoft.Web.DistributedCache.DataCacheFactoryWrapper.CreateDataCacheFromFactory(DataCacheFactory factory, String cacheName) +63
Microsoft.Web.DistributedCache.CacheHelpers.RunCacheCreationHooks(CacheConnectingEventArgs fetchingEventArgs, IDataCacheFactory dataCacheFactory, Object sender, EventHandler1 fetchingHandler, EventHandler1 fetchedHandler) +306
Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateInternalProvider(IHttpRuntime httpRuntime, SessionInitializationData initData, IDataCacheFactory dataCacheFactory, EventHandler1 cacheFetching, EventHandler1 cacheFetched) +399
Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.GetInternalProvider() +315
Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateNewStoreData(HttpContext context, Int32 timeout) +59
System.Web.SessionState.SessionStateModule.InitStateStoreItem(Boolean addToContext) +160
System.Web.SessionState.SessionStateModule.CompleteAcquireState() +340
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +1269
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12698078
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
Can anyone tell me what is happening here? How can I fix this?
Is there something missing in that tutorial that I need to do?
EDIT: I am using VS2010 Professional, with Windows Azure SDK 2.1. Widnows Azure Cache package is v2.1.0.
Relevant web.config sections:
<system.web>
...
<!-- Windows Azure Caching session state provider -->
<sessionState mode="Custom" customProvider="AFCacheSessionStateProvider">
<providers>
<add name="AFCacheSessionStateProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="default" dataCacheClientName="default" applicationName="AFCacheSessionState"/>
</providers>
</sessionState>
...
<sytem.web>
<dataCacheClients>
<dataCacheClient name="default">
<!--To use the in-role flavor of Windows Azure Caching, set identifier to be the cache cluster role name -->
<autoDiscover isEnabled="true" identifier="SessionStateDemo" />
</dataCacheClient>
</dataCacheClients>
Based on this thread it looks like the Windows Azure Cloud Service must be a startup project to work properly. Otherwise the Windows Azure Runtime won't initialize what causes the SocketExceptions.

EF Code First - Timeout expired. The timeout period elapsed prior to completion

Apology for this strangely worded question. I don't know what the actual problem is but hopefully someone can give me some insights.
I am getting the following error when trying to run migrations:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
It is interesting to note that on my laptop this is not happening but on my VM (azure - large) this is happening with 100% failure rate.
I am using Ef 6.0.0 -rc1. Please note, updating EF is not an option. If updating to EF 6.0.0 or 6.0.1 I will get the following error with 100% failure rate:
Errors during Code First add-migration
I have also timed the error. It takes about 1.5 min to trigger the error. When running with -Verbose flag it was trying to create 200 tables with indexes. Copying the sql query and excuting it in SSMS takes 5 secs.
A few things that I have tired but didn't work:
1) Setting ObjectContext.CommandTimeout = 36000 // 10 hours! as indicated here:
https://stackoverflow.com/a/6234593/305469
2) Setting timeout in connection string in "web.config":
connectionString="Data Source=localhost;Initial Catalog=myDB;Integrated Security=SSPI;Connection Timeout=36000"
3) Setting "machine.config" transaction maxTimeout:
<system.transactions>
<machineSettings maxTimeout="00:00:00" />
</system.transactions>
4) Setting "remote query timeout" on sql server
USE MyDB;
GO
EXEC sp_configure 'remote query timeout', 0 ;
GO
RECONFIGURE ;
GO
So what is happening? How come CommandTimeout is not being respected? Any suggestions?
Full trace as follows:
System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TInterceptionContext,TResult](Func`1 operation, TInterceptionContext interceptionContext, Action`1 executing, Action`1 executed)
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext)
at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery()
at System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClass32.<ExecuteStatements>b__2e()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.ExecuteStatements(IEnumerable`1 migrationStatements)
at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, XDocument targetModel, IEnumerable`1 operations, IEnumerable`1 systemOperations, Boolean downgrading, Boolean auto)
at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClassc.<Update>b__b()
at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
ClientConnectionId:8cbbc70c-8182-417e-9aca-4603f797340d
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
In the constructor of Configuration.cs class (in migration Folder) add the property CommandTimeout = Int32.MaxValue;
I restarted the SQL Server service (Win7 - Computer Management > Services and Applications > Services)
An FYI EF Migrations pull their timeout from a separate configuration:
public class MyContextConfiguration : DbMigrationsConfiguration<MyContext>
{
public MyContextConfiguration()
{
CommandTimeout = 900;
}
}
Change the 900 to a something higher, all of the other SQL timeout changes (web.config, etc.) did not do anything, this worked for me.
For me, the problem was that that migration script took a long time to run (15 minutes).
This is how I worked around the issue:
1. Run update-database -script (-force may be necessary)
2. Copy this SQL script output and run in SQL Server Management Studio
I ran into this in my production environment because it was producing queries like the ones here: Why does Entity Framework 6 generate complex SQL queries for simple lookups?
This is actually related to a bug in this version of EF: https://entityframework.codeplex.com/workitem/2083
They changed the default null semantics from 5 to 6 so I'm guessing you had the same problem I did after upgrading. My machine had a fraction of the data as my remote installation and until I got to production I didn't know I had a performance issue. The queries will often produce a table scan which will time out for larger tables.
To change it back so that it works like EF5 you have to set:
DbContextConfiguration.UseDatabaseNullSemantics = true
See here: http://msdn.microsoft.com/en-us/library/system.data.entity.infrastructure.dbcontextconfiguration.usedatabasenullsemantics(v=vs.113).aspx
The bug was fixed in EF 6.1 but you still have to set the option above to get simple where conditions.
I just had the same exact issue, i know this thread is a year old but maybe it will help someone else.
I was trying to create the database in entity 5 using the Package Manager Console using the connection string below.
update-database -ConfigurationTypeName My.Project.EF.Migrations.Configuration -ConnectionStringName MyDatabaseDev -ProjectName Project.Name -StartUpProjectName Database.Name
Each time i ran it i got the error below.
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
To fix it i simply added the -force parameter and it went right through.
I ran into this error as well and tried using various command timeout settings and found nothing was working. After awhile I discovered that my issue wasn't a timeout issue but a SQL transaction issue. Apparently, my code was conflicting with a SQL transaction that I had previously ran. At the time, the transaction was not committed or rolled back. Once I ran my COMMIT statement the issue resolved itself.
Remember to always COMMIT or ROLLBACK your transactions.
Verify if no has some transaction openned, this happened today with me and caused timeout to execute Scaffold-DbContext command, Because the DataBase is locked and the Scaffold-DbContext command canĀ“t run.
Close all transaction openned and try again.

Server Error in '/' Application. Unspecified error [ 5,sqlcese40.dll ]

Can somebody please help me?
After receiving an email from Google yesterday that advised a couple of links in my site (www.bigint.biz) were broken, I repaired them. Then I made a change to the sitemap.
Afterwards, when accessing the site I received the message: Server Error in '/' Application, Runtime Error, This tag should then have its "mode" attribute set to "Off".
So, I put the site exactly back how it was before the changes to the sitemap; but, I received
an internal server error 500 error message.
Then, I removed the whole site from the host provider and uploaded it again with the original version that worked fine with no joy.
Since, I have set the customErrors tag "mode" attribute to "Off" to get a more detailed error message - below:
Server Error in '/' Application.
Unspecified error [ 5,sqlcese40.dll ]
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.SqlServerCe.SqlCeException: Unspecified error [ 5,sqlcese40.dll ]
Source Error: Line 2: #{ Line 3: Line 4: WebSecurity.InitializeDatabaseConnection("PhotoGallery", "UserProfile", "UserId", "Email", true);
Source File: \web-123win\winpackage22\XXX.COM\web\content_AppStart.cshtml Line: 4
Stack Trace:
[SqlCeException (0x80004005): Unspecified error [ 5,sqlcese40.dll ]]
System.Data.SqlServerCe.SqlCeConnection.Open(Boolean silent) +2182
System.Data.SqlServerCe.SqlCeConnection.Open() +47
WebMatrix.Data.Database.EnsureConnectionOpen() +44
WebMatrix.Data.<QueryInternal>d__0.MoveNext() +66
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +164
WebMatrix.Data.Database.QuerySingle(String commandText, Object[] args) +103
WebMatrix.WebData.DatabaseWrapper.QuerySingle(String commandText, Object[] parameters) +14
WebMatrix.WebData.SimpleMembershipProvider.CheckTableExists(IDatabase db, String tableName) +57
WebMatrix.WebData.SimpleMembershipProvider.CreateTablesIfNeeded() +49
WebMatrix.WebData.WebSecurity.InitializeMembershipProvider(SimpleMembershipProvider simpleMembership, DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean createTables) +73
WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +51
WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(String connectionStringName, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +51
ASP._Page__appstart_cshtml.Execute() in \\web-123win\winpackage22\bigint.biz\www.bigint.biz\web\content\_AppStart.cshtml:4
System.Web.WebPages.ApplicationStartPage.<ExecuteInternal>b__0() +65
System.Web.WebPages.ApplicationStartPage.<GetSafeExecuteStartPageThunk>b__3(Action action) +7
System.Web.WebPages.ApplicationStartPage.ExecuteInternal() +78
System.Web.WebPages.ApplicationStartPage.ExecuteStartPageInternal(HttpApplication application, Action`1 monitorFile, IVirtualPathFactory virtualPathFactory, IEnumerable`1 supportedExtensions) +184
System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application, Action`1 monitorFile, IVirtualPathFactory virtualPathFactory, IEnumerable`1 supportedExtensions) +30
[HttpException (0x80004005): Exception of type 'System.Web.HttpException' was thrown.]
System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application, Action`1 monitorFile, IVirtualPathFactory virtualPathFactory, IEnumerable`1 supportedExtensions) +96
System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application) +170
System.Web.WebPages.WebPageHttpModule.StartApplication(HttpApplication application, Action`1 executeStartPage, EventHandler applicationStart) +126
System.Web.WebPages.WebPageHttpModule.StartApplication(HttpApplication application) +71
System.Web.WebPages.WebPageHttpModule.Init(HttpApplication application) +127
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +418
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Exception of type 'System.Web.HttpException' was thrown.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9874568
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
I noticed that when I was uploading the site again using FileZilla Client that 4 files failed to copy to the host; however, the same files are in the host bin directory as they did not originally delete for some reason - access rights I think. The files are:
web/content/bin/X86/sqlceer40ENN.dll
web/content/bin/X86/sqlceqp40.dll
web/content/bin/X86/sqlcese40.dll
web/content/bin/X86/sqlceme40.dll
Is this just coincidence, as the error message references one of these files?
Any help would be really appreciated.
Thank you.
EDIT - I have found a little more info here but I am struggling to understand how it can help me: http://www.blakepell.com/Blog/?p=227
I have got the site back up and running for the minute by removing: WebSecurity.InitializeDatabaseConnection("PhotoGallery", "UserProfile", "UserId", "Email", true);
But the issue still exists
I picked this problem up again today all this time later and found the solution with research. This is how I got there.
Replacing the dll files as recommended above didn't work before.
So, I started again by switching off my custom errors page which enabled me to get to get to the error code again.
I Googled the error and research pointed to a connection string issue or a folder permissions issue.
It's a good job I checked the permissions again because I previously set the folder permissions in the App_Data folder where the .sdf database was to enable read and write access using FileZilla but nothing actually changed. It seemed to work because changes appeared to cascade down through all the sub directories, but it didn't work.
The permissions were not actually changed using the FTP method although it looked like it had happened. I only found out because another post that I saw today suggested changing permissions through the control panel so I went back there to check them only to see a padlock by the folders.
So, I unlocked the folder permissions on App_Data correctly this time in the control panel file manager. I then un-commented the web security code below in the _AppStart page again and tried the site online and it worked.
Finally, I set custom errors back to on.
The moral is use the control panel and not FTP client to change folder permissions on hosted folders. I hope this helps someone else.

Server Error in '/' Application (ASP.NET)

I just setup up member ship roles and registration on my website with visual web developer using the tutorial on msdn. It works perfectly locally, but when i uploaded it to my server, I get the following page:
"Server Error in '/' Application.
--------------------------------------------------------------------------------
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.
Source Error:
[No relevant source lines]
Source File: machine.config Line: 160
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016 "
Does anybody know why I'm seeing this and how I may go about fixinf this? Any help is greatly appreciated.
Thank you
Bael.
EDIT:
I have just looked at my web.config file after reading the following line in the error message: "The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty." ... And have noticed that the following element is completely empty:
<connectionStrings/> // Is this one supposed to be empty? if not what should go here? In the error it implies it shouldn't be empty. Also, I don't know where I should place LocalSqlServer
LATEST EDIT
After changing DataSource to LocalHost i get the following error:
Server Error in '/JTS' Application.
--------------------------------------------------------------------------------
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
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: 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
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.
Stack Trace:
[SqlException (0x80131904): 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849015
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) +4862333
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +90
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +342
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +221
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +189
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +31
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +433
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +499
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +65
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
System.Data.SqlClient.SqlConnection.Open() +122
System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +87
System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +221
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) +815
System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +105
System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved) +42
System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +78
System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +60
System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +119
System.Web.UI.WebControls.Login.AttemptLogin() +115
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +101
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
Ensure you have connection string named LocalSqlServer added connectionStrings element of your Web.config.
If you're using standard ASP.NET Membership/Role providers, by default they are declared as this:
<membership>
<providers>
<add
name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, ..."
connectionStringName="LocalSqlServer" ...
It's the connectionStringName which is likely to be causing this error. If you plan on using Membership/Role API, you'll have to either add a connection string named LocalSqlServer to <connectionString> secion of your Web.config, or change connectionStringAttribute so that its value will be a valid (and existing) connection string name.
LocalSqlServer is a default connection string entry in machine.config. It is always present although not in the app/web config file.
It points to your local instance of sqlexpress that was installed with visual studio.
By default the membership provider, upon configuration, creates a local .mdf file in your app_data folder (click show all files). This database has been provisioned.
If for some reason you want to use a different database you must provision it with aspnet_regsql.exe . You will find it in your windows/microsoft.net/framework/2.0.xxxx directory.
from the commandline run aspnet_regsql.exe /? to get instructions.
So.. this may be why you are getting these errors. If you DO want to use a different database and do not want to edit the membership section to point to the new db you must remove localSqlServer and then re-add
OR, again, configure your membership element to point to a different connection.
EITHER WAY you need a PROVISIONED database other than the local user instance that was provisioned by VS that you are using during development and a connection string that points to it.
<connectionStrings>
<remove name='LocalSqlServer' />
<add name='LocalSqlServer' connectionString='Data Source=DBServerName;
Integrated Security=false;Initial Catalog=DBName;
User ID=DBLogin;Password=DBPassword' providerName='System.Data.SqlClient' />
</connectionStrings>
EDIT: reread your question:
The problem is that the host does not have sql or does not allow user instances. Typically in a hosted site, you will request a database and upon getting the credentials, use aspnet_regsql.exe to provision that database. In this case you MUST modify the membership section in web.config to point to your new database.
hth
If you have .Net membership roles provider see this link first.
Some explanation since you said you did not understand
Net membership roles provider is setup to look for 'LocalSQLServer'. This means that we have to supply the details for a connection named LocalSQLServer or say it isnt needed. What you can do is in you web.config file find the <connectionstrings> part and add a line:
<add name='LocalSqlServer' connectionString='Data Source=DBServerName;
Integrated Security=false;Initial Catalog=DBName;
User ID=DBLogin;Password=DBPassword' providerName='System.Data.SqlClient' />
Replace the DBServerName with your SQL db server addon, DBName with the database name that came with your addon, DBLogin and Password should be replaced with what came with your SQL addon.
If you don't want to use LocalSQLSever you can remove it by
<remove name='LocalSqlServer' />
in your web.config file under the properties. Then change the connection string name on your roles provider to the connection string name you will be using. So change your exisiting connection string to name='LocalSQLServer'.
It may be that you're getting a connection string from the machine.config.
The easiest way to get rid of these, rather than using remove is to use a self closed clear element in the connectionstrings section.
The out of the box membership provider should have had a local connection string entry (new projects get this by default). You could create a new project and swipe it from there.
On the server you'll need to check SQL is installed correctly, and to update the connection string to match the server details.
I've often seen this message when the ASPNET user does not have read access to the config directory for the framework in question. It looks to me like you have a file directive in one of your keys, and the framework does not have access (either through permissions or because the file is not there) to read it.
Enable Named Pipes and TCP/IP for Microsoft SQL Server

Categories

Resources