Problem loading Oracle client libraries when running in a NAnt build - nant

I am trying to use dbdeploy to manage Oracle schema changes. I can run it successfully from the command line to get it to generate my change scripts, but when I try to execute it via the dbdeploy NAnt task running through TeamCity, I get an error:
System.Data.OracleClient requires Oracle client software
version 8.1.7 or greater.
I do have the Oracle 10.2.0.2 client software installed. It's the first entry in the system path, and the dbdeploy.exe app is able to successfully negotiate an Oracle connection. The dbdeploy code dynamically loads the System.Data.OracleClient assembly, which in-turn tries to use the Oracle client bits to talk to the database. This is what is failing in my NAnt environment.
I have verified the following points:
The same user identity is running the process in both cases
The same working directory is used in both cases
The same dbdeploy code is running in both cases and with the same supplied parameters
The same database connection string is being used in both cases
The same ADO.NET assembly is being dynamically loaded in both cases (System.Data.OracleClient, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
Here's the top of the stack trace during the error:
at System.Data.OracleClient.OCI.DetermineClientVersion()
at System.Data.OracleClient.OracleInternalConnection.OpenOnLocalTransaction
(String userName, String password, String serverName,
Boolean integratedSecurity, Boolean unicode, Boolean omitOracleConnectionName)
at System.Data.OracleClient.OracleInternalConnection..ctor(
OracleConnectionString connectionOptions)
at System.Data.OracleClient.OracleConnectionFactory.CreateConnection(
DbConnectionOptions options, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningObject)
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.OracleClient.OracleConnection.Open()
at Net.Sf.Dbdeploy.Database.DatabaseSchemaVersionManager.
GetCurrentVersionFromDb()
My main question is this: how can I discover what's different about these running environments to see why my Oracle client software can't be loaded?

Related

Database from AlwaysOn availability group restored as normal database

I have a problem with a normal SQL database restored from a DB set in AlwaysOn high availability group in SQL Server 2017.
I restored a copy of production db to a different server, to be used as QA test database, with a different name also - MyDB_demo
The problem is, the QA app copy (same code as production with new development enhancements) get an error at some point.
Even if my conn str points to MyDB_demo, I get the following error
[SqlException (0x80131904): The target database ('MyDB') is in an availability group and is currently accessible for connections when the application intent is set to read only. For more information about application intent, see SQL Server Books Online.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action 1 wrapCloseInAction) +2444190
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action 1 wrapCloseInAction) +5775712
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +285
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4169
System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +58
System.Data.SqlClient.SqlDataReader.get_MetaData() +89
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption) +409
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +2127
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +911
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +64
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +240
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +41
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +12
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +139
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +136
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +88
MyApp.SqlHelper.ExecuteDataset(SqlConnection connection, CommandType commandType, String commandText, SqlParameter[] commandParameters) +163
MyApp.PermitFunctions.GetSystemMessages(String sp, Int32 iPermitID, Int32 iAppID, SqlConnection cn) +219
MyApp.Municipality.LoadSystemMessage() +3869
MyApp.Municipality.Page_Load(Object sender, EventArgs e) +101
System.Web.UI.Control.OnLoad(EventArgs e) +95
System.Web.UI.Control.LoadRecursive() +59
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678
Is there any reference in the newly restored DB (named now MyDB_demo) that stores the original name of production DB and why is it trying to access it?
Any suggestion is appreciated.
EDIT
Actually, the server used to restore MyDB_demo is one of the secondary nodes for AlwasyOn availability group; it also contains a RO copy of production database, MyDB.
So the server has:
RO copy of production DB (MyDB)
normal, stand-alone db restored for QA - MyDB_demo
Hence, I understand the error message - it would makes sense if I tried to access directly the secondary, RO copy of production db from connection string.
But I do not: the connection string (which I double-checked) is trying to connect to QA db, MyDB_demo.
Here is some additional info:
the error is thrown in SQLHelper class, the helper class from MS to work with SQL Server, in the ExecuteDataset function
the error is thrown ONLY on one stored procedure - lot of other stored procedures and also direct SQL statements run just fine
I inspected the stored procedure, thinking it might contains accidentally a hardcoded reference to DB name - it doesn't
and the strange part - I run the stored procedure with the same parameters as called from the app in SSMS - and it run just fine - no error
So it looks somehow the connection string MIGHT be altered (!!!) is some way by the NET application itself, and only for this stored procedure?
Anyone ever encountered something like this?
Thank you
Due to the strange (read: stupid) situation that the culprit SP fails only when called from within app, but runs ok when tried in SSMS, I tried a "stupid" approach: I inspected its code, commented out two fields that were set with sub-selects like select top 1 from ..... where.... (actually I replaced theit values with dummy ones) and I changed an Order By field that was initially specified like "InspectionType" Desc, which I removed quotation marks from.
Doing this, the SP suddenly started to work ok even when called from the app.
Then I reverted all changes to original (added quoted back and put back the sub-selects) and the SP continued to work ok.
So ... problem solved.
Stupid approach for stupid problem (!?!?!)
In any case, if anyone has a better idea or explanation of what might have happened, I'd be glad to hear it
EDIT
I think I understand the fix.
By editing and saving the stored procedure, its query plan was recompiled.
So the original error might have been caused by the old query plan.
But why did it referenced the database name? Is the actual database name referenced in query plans? This looks a little odd to me.
And another question (open):
Does the SQL Server optimizer detect if a DB runs in high-availability mode, and when optimizing the queries, does it decide if a query is read-only mode and automatically redirects it toward a read-only node? Even if the ApplicationIntent readonly parameter is not present in connection string?
Because it was not in this case, even in production - we just implemented AlwaysOn functionality and are in the process of updating app to take advantage of R/O nodes.
Any comments are appreciated

Injected database context fails to connect at high load

I am using AutoFac for dependency injector in web api project.
I am resolving dependency like below...
builder.RegisterType<DbContext>().InstancePerRequest().WithParameter("nameOrConnectionString", "name=TestDbContext");
builder.RegisterType<TestDbContext>().InstancePerRequest();
builder.RegisterType<TestDbContext>().As<ITestDbContext>().InstancePerRequest();
builder.RegisterType<TestDbRepository>().As<ITestDbRepository>().InstancePerRequest();
It is working fine when hit a single api route. But when our QA team doing performance testing with jMeter which hitting multiple request at a time, some of requests get fail and get db related error, like below errors...
The underlying provider failed on Open.
System.InvalidOperationException: The connection was not closed. The connection's current state is connecting.
at System.Data.ProviderBase.DbConnectionClosedConnecting.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext)
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.Core.EntityClient.EntityConnection.Open()
But this error is not consistent some times it get passed but some times this error comes.
Please help me if any thing we need to modify with Autofac dependency resolver.

"An exception has been raised that is likely due to a transient failure" - running Nunit from jenkins

I am running datalayer test cases using Nunit from Jenkins. The testcases uses entityframework to connect with database. My connection string:
When I am running this test cases from Jenkins I am getting below
error:
2) Test Error : TaskMaster.Tests.TaskManagerControllerTest.EndTask System.Data.Entity.Core.EntityException : An exception has been raised
that is likely due to a transient failure. If you are connecting to a
SQL Azure database consider using SqlAzureExecutionStrategy. ---->
System.Data.Entity.Core.EntityException : The underlying provider
failed on Open. ----> System.Data.Entity.Core.EntityException : An
exception has been raised that is likely due to a transient failure.
If you are connecting to a SQL Azure database consider using
SqlAzureExecutionStrategy. ----> System.Data.SqlClient.SqlException
: A connection was successfully established with the server, but then
an error occurred during the login process. (provider: Named Pipes
Provider, error: 0 - No process is on the other end of the pipe.)
----> System.ComponentModel.Win32Exception : No process is on the other end of the pipe at
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func1
operation) at
System.Data.Entity.Core.Objects.ObjectQuery1.GetResults(Nullable1
forMergeOption) at
System.Data.Entity.Core.Objects.ObjectQuery1..GetEnumerator>b__0()
at System.Data.Entity.Internal.LazyEnumerator1.MoveNext() at
System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at
TaskMaster.Data.Repository.GetTasks() in c:\Program Files
(x86)\Jenkins\workspace\Test001\TaskMaster.Data\Repository.cs:line 30
at BusinessLayer.TaskManager.GetTasks() in c:\Program Files
(x86)\Jenkins\workspace\Test001\BusinessLayer\TaskManager.cs:line 34
at TaskMaster.Tests.TaskManagerControllerTest.EndTask() in c:\Program
Files
(x86)\Jenkins\workspace\Test001\TaskMaster.Tests\TaskManagerController.Test.cs:line
62
--EntityException at System.Data.Entity.Core.EntityClient.EntityConnection.Open() at
System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean
shouldMonitorTransactions) at
System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func1
func, IDbExecutionStrategy executionStrategy, Boolean
startLocalTransaction, Boolean releaseConnectionOnSuccess) at
System.Data.Entity.Core.Objects.ObjectQuery1.<>c__DisplayClass7.b__5()
at
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func1
operation)
--EntityException at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func1
operation) at
System.Data.Entity.Core.EntityClient.EntityConnection.Open()
--SqlException at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1
retry) at System.Data.SqlClient.SqlConnection.Open() at
System.Data.Entity.Infrastructure.Interception.InternalDispatcher1.Dispatch[TTarget,TInterceptionContext](TTarget
target, Action2 operation, TInterceptionContext interceptionContext,
Action3 executing, Action3 executed) at
System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection
connection, DbInterceptionContext interceptionContext) at
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
at
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func1
operation)
--Win32Excepti
If I run the same test cases from visual studio tests run fine without any error. I have checked the connection string are same. Any help appreciated.
Note: I tried to use Integrated security in connection string. But in jenkins tries to login in database as NT Authority/Network Service and that user is not present.

MigrateDatabaseToLatestVersion and dbo.__MigrationHistory

I am trying to deploy an MVC4 application that is built using EF5 codefist and migrations.
I want the app to update the database when I in the future deploy new versions of the app with new migrations, so in Global.asax I do this:
Database.SetInitializer(new MigrateDatabaseToLatestVersion<GoDealMvc4Context, Configuration>());
using (var ctx = new GoDealMvc4Context()) {
ctx.Database.Initialize(false);
}
The initial database on the server is deployed by attaching an MDF file copied from my dev machine. This database contains the __MigrationsHistory system table. So this database should not need to execute any migrations, because it is up to date with latest migration.
When I try to start the app on the server, it I get this error:
There is already an object named 'UserProfile' in the database.
[SqlException (0x80131904): There is already an object named 'UserProfile' in the database.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +388
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +688
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4403
System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout) +2755286
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +527
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +290
System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement) +247
System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements) +202
System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration) +472
System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId) +175
System.Data.Entity.MigrateDatabaseToLatestVersion`2.InitializeDatabase(TContext context) +150
System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +66
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +225
System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +208
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +235
GoDeal.Mvc4.MvcApplication.Application_Start() +342
So apparently the app thinks it needs to apply a migration even though the __MigrationHistory table is present in the database with this content:
MigrationId Model ProductVersion
201210161046508_initial 0x1F8... 5.0.0.net45
and the app contains a single migration class:
201210161046508_initial.cs:
public partial class initial : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.UserProfile",
....
So my questions are:
1) why do my application think it needs to apply this migration when the contents of the __MigrationsHistory table is as described.
2) is this the recommended way of making an application that automatically applies new migrations wehn restarted on a new version.
There is also another NASTY gotcha here for anyone looking for answers. Check the content of the
[dbo].[__MigrationHistory] table column ContextKey
This table Tells how the DB was created (migration mode, Create mode etc...) was created. AND with what Migration Configuration Program. I got hurt with a change of MigrationsConfiguration Class name.
Changing the entry in table worked :-) Or renaming your code back.
1)
As your migration is called "initial" rather than "InitialCreate" this implies that you created this manually and when you enabled code first migrations the database didn't exist already. Or at least the context was not pointing to it. http://msdn.microsoft.com/en-us/data/jj591621.aspx
I believe that MigrateDatabaseToLatestVersion will first trying the create the entity tables for entities that existed before migrations was enabled. As the InitialCreate migration does not exist in your database this first step will then clash with the tables that already exist. Sorry this is a bit vague but I don't fully understand it. To fix this I would remove the migrations by deleting them (first saving any custom changes) and then enable them again with the context pointing at the exiting DB. You should now have an "InitialCreate" migration. You should now be able to copy up the db and use MigrateDatabaseToLatestVersion in the production environment.
2)
Personally letting code first update a production DB worries me quite a bit. I have been using update-database -script -sourcemigration xx to generate the scripts to migrate the DB. This way you can see what is going to happen before you break anything. It also allows you to run in a transaction and roll back after a failure.
In my case this issue was caused by missing migration. I did some changes into model, but I forgot to create new migration file.
My solution is to run in Package Manager Console: Add-Migration MyMigrationName
Just in case someone else encounters SqlException with the message There is already an object named '<TABLE_NAME>' in the database. after changing the model while using automatic migrations. It seems the migrations' Configuration requires in some cases explicit naming of the context key:
internal sealed class Configuration : DbMigrationsConfiguration<MyDatabaseContext>
{
public Configuration ()
{
AutomaticMigrationsEnabled = true;
ContextKey = "MyNamespace.MyDatabaseContext"; // this line was missed
}
protected override void Seed(MyDatabaseContext context)
{
}
}
After adding the line above to the constructor of Configuration, the migration ran without any issues. You can check which ContextKey value is already in use in the __MigrationHistory database.

Unavailable XRMServices/2011/Organization.svc

I try to discover service endpoint .../XRMServices/2011/Organization.svc and I've this error:
An error has occurred.
Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization's Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support.
System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Crm.MainApplication.Application_Error(Object sender, EventArgs eventArguments)
Stack trace:
Error Description:
Generic SQL error.
Error Details:
Generic SQL error.
Full Stack:
[SqlException: Cannot open database "ASPState" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]
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.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.SessionState.SqlSessionStateStore.SqlStateConnection..ctor(SqlPartitionInfo sqlPartitionInfo, TimeSpan retryInterval)
[HttpException: Unable to connect to SQL Server session database.]
at System.Web.SessionState.SqlSessionStateStore.ThrowSqlConnectionException(SqlConnection conn, Exception e)
at System.Web.SessionState.SqlSessionStateStore.SqlStateConnection..ctor(SqlPartitionInfo sqlPartitionInfo, TimeSpan retryInterval)
at System.Web.SessionState.SqlSessionStateStore.GetConnection(String id, Boolean& usePooling)
at System.Web.SessionState.SqlSessionStateStore.DoGet(HttpContext context, String id, Boolean getExclusive, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actionFlags)
at System.Web.SessionState.SqlSessionStateStore.GetItemExclusive(HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actionFlags)
at System.Web.SessionState.SessionStateModule.GetSessionStateItem()
at System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData)
at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
What may cause the problem, what is wrong with CRM?
Since you are using NETWORK SERVICE, you need to make sure the webserver's computer account is added to the SQLAccessGroup in Active Directory. Normally this is done for you during CRM setup, but if you want to change the account later you must remember to add the new account to this group manually. Here is a link that describes the different groups that CRM uses:
http://ayazahmad.wordpress.com/2007/01/26/active-directory-security-groups-for-mscrm/
I've seen a similar message when the user did not have a role assigned, but that occured in a test enviroment, still worth checking.
I completely re-installed development stack and the same happened again, I re-installed my virtual machine and it worked, seems like it some unknown issue. Now I'll try to reproduce the same errors on a new instances of a virtual machine.
Thanks to all)
I have seen also this message on my CRM server. What I've done is to just enable and disable anonymous authentication on IIS, and thing worked for me. Also I've played with web.config, service settings, but later I get that section back as it was on first install of CRM.
In my oppinion, IIS doesn't tell WCF how to auth, and couple of cold restarts, and enabling and disabling anonymous auth. wake up WCF.
Your AppPool needs to be a User that has access to the database.
With regards to the WCF Service,
Check your IIS Website Authentication settings, for WCF Services you need
Anonymous Authentication Enabled
ASP.NET Impersonation Enabled
Windows Authentication Enabled
for On-Premise installation running in an AD environment.
We also had the issue and it was resolved after restarting IIS.