Azure website fails to connect to SQL Azure Database - sql

I've searched for hours and can't find anything helpful.
Using ASP.NET MVC4 with Windows Azure.
When I run the site locally on my dev machine, using the SQL Azure connection string. I can access the remote database no problem at all. However, when I deploy the site and try to access it from [mysite].azurewebsites.com I get the following error after a timeout (the connection string in Azure is identical; copy and pasted):
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)
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.
SQLExpress database file auto-creation error:
The connection string specifies a local Sql Server Express instance using a database location
within the application's App_Data directory. The provider attempted to automatically create the
application services database because the provider determined that the database does not exist.
The following configuration requirements are necessary to successfully check for existence of
the application services database and automatically create the application services database:
1.If the application is running on either Windows 7 or Windows Server 2008R2, special
configuration steps are necessary to enable automatic creation of the provider database.
Additional information is available at: http://go.microsoft.com/fwlink/?LinkId=160102. If the
application's App_Data directory does not already exist, the web server account must have read
and write access to the application's directory. This is necessary because the web server
account will automatically create the App_Data directory if it does not already exist.
2.If the application's App_Data directory already exists, the web server account only requires
read and write access to the application's App_Data directory. This is necessary because the web
server account will attempt to verify that the Sql Server Express database already exists within
the application's App_Data directory. Revoking read access on the App_Data directory from the
web server account will prevent the provider from correctly determining if the Sql Server
Express database already exists. This will cause an error when the provider attempts to create a
duplicate of an already existing database. Write access is required because the web server
account's credentials are used when creating the new database.
3.Sql Server Express must be installed on the machine.
4.The process identity for the web server account must have a local user profile. See the readme
document for details on how to create a local user profile for both machine and domain accounts.
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean
breakConnection, Action`1 wrapCloseInAction) +5296071
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean
callerHasConnectionLock, Boolean asyncClose) +558
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds
connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean
trustServerCert, Boolean integratedSecurity, Boolean withFailover) +5308555
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String
newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout,
Boolean withFailover) +145
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String
newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString
connectionOptions, SqlCredential credential, TimeoutTimer timeout) +920
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout,
SqlConnectionString connectionOptions, SqlCredential credential, String newPassword,
SecureString newSecurePassword, Boolean redirectedUserInstance) +307
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity,
SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String
newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString
userConnectionOptions) +434
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options,
DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
owningConnection, DbConnectionOptions userOptions) +5311099
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection
owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) +38
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,
TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
+5313314
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection,
DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions
userOptions) +143
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +83
System.Data.SqlClient.SqlConnection.Open() +96
System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password,
Boolean trusted, String connectionString) +76
[HttpException (0x80004005): Unable to connect to SQL Server database.]
System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password,
Boolean trusted, String connectionString) +131
System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String
password, Boolean trusted, String connectionString, String database, String dbFileName,
SqlFeatures features, Boolean install) +89
System.Web.Management.SqlServices.Install(String database, String dbFileName, String
connectionString) +27
System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName, String dataDir,
String connectionString) +386
I tried to look at the remote web.config file using ftp but every time I try to "Set up deployment credentials" I get this error:
Failed to Set Credentials with error: 'Publishing username is already used. Specify a different publishing username.'
Which is BS because there is no "Deployment / FTP User" set at all.
Any help would be appreciated.

It seems that the app is using the wrong connection string. Sometimes MVC 4 / EF5 has the Default Connection String as below:
<add name="MovieDBContext"
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Movies.mdf;Integrated Security=True"
providerName="System.Data.SqlClient"
/>
For me, it is still using this default connection, that's why locally is working.
Some strategies:
1-get which connection string your dbcontext is using as follows:
var myconn = db.Database.Connection.ConnectionString; //set this to a ViewBag for example
2-Just to be sure, create your connection string in web.config with the same name of your DbContext or set the connection name inside the constructor.
I now that you already have the Sql Azure Connstring, but I'll post in here too, because it could help someone else:
Default Sql Azure Connection String
Server=tcp:[serverName].database.windows.net;Database=myDataBase;
User ID=[LoginForDb]#[serverName];Password=myPassword;Trusted_Connection=False;
Encrypt=True;
you could find the right one in your management portal.

I know this is an old tread, but I will like to share my solution.
My problem was that I could run the application on the local machine with connection to SQL on Azure. And the login validation was done on the Azure SQL.
When running the app on Azure it was not possible to login, but the pages with anonymous access connects to the database proberly.
In the Azure Mangement the connection string for DefaultConnection is not changed when a project is published. I think this connection i created first time the project is publish to Azure.
After setting the default connection string to the same as in web.config everything is working smootly.

The way I resolved this issue was to FTP into the site and downloaded and viewed the connection string in web.config.
It was not what I expected it to be. I then deleted it and fixed the issue and then republished the site.
I again FTP'ed into the site and now it did have the correct connection string.
In my case, the issue was that I was using a web.release.config file, but it was incorrectly configured so it was not actually being used.

I had the same problem recently but in my case the cause was different. I had configured the Microsoft ASP.NET Universal Providers to connect to my SQL Azure database. Later on, while I was using the ASP.NET Configuration Tool to enable roles, this is what my configuration looked like.
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider" connectionStringName="hidden" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="0" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<roleManager enabled="true" />
The roleManager section was added by the configuration tool. That tool was written, however, in the days of lore when there was no such thing as Universal Providers.
See what's missing? Yeah, the roleManager section doesn't have any connection string defined. On my local machine everything worked fine, however, because this missing connection string results in a local MDF being created where the app can now store the roles, but in Azure, this doesn't work. I solved it by specifying the connection string in the same manner like this:
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider" connectionStringName="hidden" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="0" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<roleManager enabled="true" defaultProvider="DefaultRoleProvider">
<providers>
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider" connectionStringName="hidden" applicationName="/" />
</providers>
</roleManager>
Solved the problem. I did have to reconfigure all my roles, because they were sitting somewhere in a local file.

Related

Azure SQL Database: The timeout period elapsed prior to obtaining a connection from the pool

Our application has been connecting to SQL Server that resides in VM and we recently, decided to migrate to Azure SQL Database. Azure SQL Database is up and running, and we are able to connect to it from SQL Management Studio on development environment.
On the production server, we change the application connection string as follow:
Data Source=my-azure-production.database.windows.net;Initial Catalog=DummyDatabase;User ID=DummyUser;Password=password;Application Name=DummyApplication; MultipleActiveResultSets=True
When the application first connecting to Azure SQL, the application throw "InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached." (I am certain not because of connection pool issue)
When the same connection string is used on development machine, the application can connect to the database and work without issue. We run the same application on another server and we do not encounter the error too.
When the same credential is used for EF6 connection string, we get the following AggregateException:
Type: AggregateException
Message: One or more errors occurred.
StackTrace: at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at ......:line 86
Type: EntityException
Message: 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.
StackTrace: at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options)
at System.Data.Entity.Internal.InternalContext.SaveChanges()
at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
at System.Data.Entity.DbContext.SaveChanges()
at ....... :line 84
at ....... :line 97
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ..... :line 86
Type: EntityException
Message: The underlying provider failed on Open.
StackTrace: 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](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass2a.<SaveChangesInternal>b__27()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
Type: EntityException
Message: 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.
StackTrace: at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation)
at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
Type: 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: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
StackTrace: at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
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, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.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.DbConnectionDispatcher.<Open>b__36(DbConnection t, DbConnectionInterceptionContext c)
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.Core.EntityClient.EntityConnection.<Open>b__2()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
Type: Win32Exception
Message: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
StackTrace: null
The same EF6 connection string do not have the issue when application is running on development machine or another server.
We believe it is environmental related issue but have no idea how to troubleshoot this error. Any idea?
Thanks!
Does the Production server have outbound Internet access?
Your underlying error is "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond".
That sounds a lot like a firewall completely or partially blocking the connection between the app and the endpoint in Azure.
The Azure SQL database connection string doesn't has the attribute Application Name=DummyApplication;.
Please get the correct connect string from the Azure Portal:
Try to use the new connect string to connect again. You also can reference this Azure Document Quickstart: Use .NET and C# in Visual Studio to connect to and query an Azure SQL database.
Please make you have opened the firewall and allow access to Azure Service 'ON':
Add client IP and set allow access to Azure Service 'ON'
Hope this helps.

WCF working in Visual Studio but Failing Open underlying provider in IIS 7.5

I have a RESTFul project in Visual Studio that works fine in the Visual Studio development localhost, but that fails when I access it directly on IIS 7.5. I can see fine the .svc info, but accessing the method I get the error:
The underlying provider failed on Open
With all these details:
en System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
en System.Data.EntityClient.EntityConnection.Open()
en System.Data.Objects.ObjectContext.EnsureConnection()
en System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
en System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() en System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
en System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) en Service.GetBooksList() en c:\inetpub\wwwroot\JsonTestApp\App_Code\Service.cs:lĂ­nea 18 en SyncInvokeGetBooksList(Object , Object[] , Object[] )
en System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
en System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) en System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) en System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) en System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
I have been browsing long and everybody talks about the connection string, but as far as I know is OK, specially since it works fine in Visual Studio. This is my connection string that connects a SQL Server 2008 R2 Express:
<connectionStrings>
<add name="modelEntities" connectionString="metadata=res://*/App_Code.Model.csdl|res://*/App_Code.Model.ssdl|res://*/App_Code.Model.msl;provider=System.Data.SqlClient;provider connection string="data source=HP-HP\SQLEXPRESS;initial catalog=test_android;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
Can someone, please, help me? Being a newbie in this, is a painful beginning...
Thank you!
Try the connection string below on your development deployment app.
<add name="modelEntities" connectionString="Server=HP-HP\SQLEXPRESS;Database=test_android;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient"/>

Unable to authenticate to RavenDB server on local network

I am attempting to connect to RavenDB on Server2 from Server1.
On Server2 I have created a new user "RavenDBUser" and granted them read/write access to the Database directory within the RavenDB installation.
I am running RavenDB as the windows service on port 8080.
On Server1 I have set the connection string for my application to:
Url=http://server2:8080;Database=MyDatabase;Domain=server2;user=RavenDBUser;password=mypassword;
When I run my application, I get a 403, forbidden error.
However, I am able to connect to the RavenDB Studio from Server1 and view "MyDatabase" after authenticating as "RavenDBUser".
The error details can be seen below:
[WebException: The remote server returned an error: (403) Forbidden.]
System.Net.HttpWebRequest.GetResponse() +8522396
Raven.Client.Connection.HttpJsonRequest.ReadJsonInternal(Func1
getResponse) +805
Raven.Client.Connection.HttpJsonRequest.ReadResponseJson() +587
Raven.Client.Connection.ServerClient.DirectPutIndex(String name,
String operationUrl, Boolean overwrite, IndexDefinition definition)
+774 Raven.Client.Connection.<>c__DisplayClass50.<PutIndex>b__4f(String
operationUrl) +36
Raven.Client.Connection.ReplicationInformer.TryOperation(Func2
operation, String operationUrl, Boolean avoidThrowing, T& result) +194
Raven.Client.Connection.ReplicationInformer.ExecuteWithReplication(String
method, String primaryUrl, Int32 currentRequest, Int32
currentReadStripingBase, Func2 operation) +526
Raven.Client.Connection.ServerClient.ExecuteWithReplication(String
method, Func2 operation) +138
Raven.Client.Indexes.AbstractIndexCreationTask.Execute(IDatabaseCommands
databaseCommands, DocumentConvention documentConvention) +86
Raven.Client.Indexes.IndexCreation.CreateIndexes(ExportProvider
catalogToGetnIndexingTasksFrom, IDatabaseCommands databaseCommands,
DocumentConvention conventions) +108
MyApp.CMSRegistry.InitializeStore() +380 MyApp.CMSRegistry..ctor()
+66
It seems the missing piece was that you have to explicitly enable the windows user/group in the RavenDB system database configuration.
The not so easy to find docs for doing this can be found at http://ravendb.net/docs/studio/multi-database about 3/4 down the page.

WCF Service is showing error after implemented in IIS

In my project I am using Enterprise Library to connect to database. It is working fine when I run the application from Visual Studio directly.
But this is showing error connecting to database when hosted in IIS on same machine. I have added log trace and got the following error
Resolution of the dependency failed, type =
"Microsoft.Practices.EnterpriseLibrary.Data.Database", name =
"(none)". Exception occurred while: while resolving. Exception is:
InvalidOperationException - The type Database cannot be constructed.
You must configure the container to supply this value.
----------------------------------------------- At the time of the
exception, the container was:
Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,(none)
| Exception:Microsoft.Practices.ServiceLocation.ActivationException:
Activation error occured while trying to get instance of type
Database, key "" --->
Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the
dependency failed, type =
"Microsoft.Practices.EnterpriseLibrary.Data.Database", name =
"(none)". Exception occurred while: while resolving. Exception is:
InvalidOperationException - The type Database cannot be constructed.
You must configure the container to supply this value.
----------------------------------------------- At the time of the
exception, the container was:
Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,(none)
---> System.InvalidOperationException: The type Database cannot be
constructed. You must configure the container to supply this value.
at
Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.GuardTypeIsNonPrimitive(IBuilderContext
context, SelectedConstructor selectedConstructor) at
Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.PreBuildUp(IBuilderContext
context) at
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext
context) at
Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlanCreatorPolicy.CreatePlan(IBuilderContext
context, NamedTypeBuildKey buildKey) at
Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext
context) at
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext
context) at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type
t, Object existing, String name, IEnumerable1 resolverOverrides)
--- End of inner exception stack trace --- at
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object
existing, String name, IEnumerable1 resolverOverrides) at
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String
name, IEnumerable`1 resolverOverrides) at
Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type
serviceType, String key) --- End of inner exception stack trace ---
at
Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type
serviceType, String key) at
Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService](String
key) at
Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.InnerCreateDatabase(String
name)
My web.config of service is contains as below
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/>
</configSections>
<dataConfiguration defaultDatabase="OracleConnection">
<providerMappings>
<add databaseType="Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase, Microsoft.Practices.EnterpriseLibrary.Data" name="Oracle.DataAccess.Client"/>
</providerMappings>
</dataConfiguration>
<connectionStrings>
<add name="OracleConnection" providerName="Oracle.DataAccess.Client" connectionString="User Id=***;Password=****;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=*****)(PORT=1500)) (CONNECT_DATA=(SERVER = DEDICATED) (SERVICE_NAME =*****)));"/>
<add name="SybaseConnection" connectionString="providerName=Sybase.ASEOLEDBProvider;Server=****;Port=5050;Catalog=**;User Id=***;Password=****"/>
</connectionStrings>
I tried a lot but unable to find the cause of issue. :(
I checked the permission on the folder and Everyone has full control. WCF Service in IIS Anonymous access is enabled.
Could anyone please help?
The assembly you are using cannot find one of the assemblies it depends on, make sure all dependencies are either in the GAC or in the bin folder of your web app.
When i enabled 32 bit applications in IIS the error has been changed to
ORA-12638: Credential retrieval failed
The connection string is correct which is working with visual studio.
Is there any setting we need to do in Oralce part to acces connection from IIS?
This worked fine when updated sqlnet.ora file of oracle.

Security exception on IIS 7.5 with no shared folder

I get an exception after upgrading Spring.NET 1.2 to 1.3 in my web application. Here's the setup on my web app:
I created an application pool with its identity set to ApplicationPoolIdentity. I use NHibernate 2.1, my SQL Server 2008 is local and I'm using SQL server authentication. There's no network or shared folder. Everything is local.
Now the weird thing is that if I change identity of my application pool in IIS to NetworkService, it starts working fine. I wonder what is the problem with setting the identity of my application pool to ApplicationPoolIdentity.
Here's the exception:
System.Configuration.ConfigurationErrorsException: Error creating context '/project1': That assembly does not allow partially trusted callers. ---> Spring.Objects.Factory.ObjectCreationException: Error thrown by a dependency of object 'MyObj' defined in 'file [D:\Projects\MyProject\Configs\Services.xml] line 37' : Initialization of object failed : Failed to create an instance of 'Spring.Data.NHibernate.Bytecode.ProxyFactoryFactory'!
while resolving 'Sleepers[0]' to 'CustomerManager' defined in 'file [D:\Projects\MyProject\Configs\Business.xml] line 64'
while resolving 'CustomerDAO' to 'CustomerDAO' defined in 'file [D:\Projects\MyProject\Configs\Dao.xml] line 50'
while resolving 'SessionFactory' to 'SessionFactory' defined in 'file [D:\Projects\MyProject\Configs\Dao.xml] line 21' ---> NHibernate.Bytecode.HibernateByteCodeException: Failed to create an instance of 'Spring.Data.NHibernate.Bytecode.ProxyFactoryFactory'! ---> System.Security.SecurityException: That assembly does not allow partially trusted callers.
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type)
at NHibernate.Bytecode.AbstractBytecodeProvider.get_ProxyFactoryFactory()
The action that failed was:
LinkDemand
The assembly or AppDomain that failed was:
NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
The Zone of the assembly that failed was:
Internet
The Url of the assembly that failed was:
file:///D:/Projects/MyProject/bin/NHibernate.DLL
--- End of inner exception stack trace ---
IIS is trying to load and execute the assembly from the address: file:///D:/Projects/MyProject/bin/NHibernate.DLL.
Executing this will solve those permission issues within that machine:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -addgroup 1.2 -url
"file:///D:/Projects/MyProject/bin/*" FullTrust